Skip to content Skip to sidebar Skip to footer

Include Javascript File In A Single-file Shiny App

I need to include a js file in a single-file shiny app. I tried to work with a two file app (classic UI-Server) and it works, but when I try to add the Javascript file into a singl

Solution 1:

To add to the solution:

If you want to include a js file from server, use:

ui = fluidPage(

useShinyjs(),
tags$head(tags$script(src="https://tab.worldbank.org/javascripts/api/tableau-2.min.js")))

If you want also want to include customized local js functions, add additional line with your path + js file name, e.g.:

extendShinyjs(script = "C:/Users/Desktop/YourFile.js")

Note here: in each js function inside extendShinyjs, it should be prefixed using shinyjs. e.g.:

shinyjs.switchView = function(sheetname) {
 var workbook = viz.getWorkbook();
 workbook.activateSheetAsync(sheetname);
 }

Post a Comment for "Include Javascript File In A Single-file Shiny App"