Hi @xiaoni,
Welcome to the RStudio community!
To answer your questions, the extendShinyjs function is used "for running arbitrary code" shinyjs. Loading scripts isn't possible using this method. Instead, you can use the functions includeScript() or tags$script(src = "path/to/js/"). These functions are included in the shiny package.
For example, if you were using the standalone D3 file in a shiny app, here's how you would load the scripts and use in a separate js file. (I would also recommend saving copies into the www folder).
Directory Structure
my-shiny-app /
- ui.R
- server.R
- www/
- d3v5.min.js
- index.js
ui.R
ui <- tagList(
tags$svg(id = "box"),
tags$script(src = "d3v5.min.js"),
tags$script(src = "index.js")
)
index.js
# d3 is available since it's loaded before
const elem = d3.select("box");
# do something ...