Having an issue with html widgets in my r shiny app if I add a script.js

Everything is fine and working until I add my custom scripts.js file. Then no content shows on pages and I get the following error which I can't get to the bottom of.

16htmlwidgets.js:498 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'filter')
at shinyBinding.find (htmlwidgets.js:498:38)
at bind.ts:281:29
at m (bind.ts:2:1357)
at Generator. (bind.ts:2:4174)
at Generator.next (bind.ts:2:2208)
at ZP (bind.ts:3:99)
at f (bind.ts:4:194)
at bind.ts:4:364
at new Promise ()
at bind.ts:4:97

I do not create any custom widgets that would require binding.

I am loading the following libraries

library(highcharter)
library(yaml)
library(shiny)
library(shinyjs)
library(shiny.fluent)
library(shiny.router)
library(imola)
library(shinyWidgets)
library(tibble)
library(dplyr)
library(tidyverse)
library(lubridate)
library(readr)
library(forcats)
library(purrr)
library(glue)
library(patchwork)
library(sjmisc)
library(scales)
library(ggthemes)
library(RColorBrewer)
library(forecast)

and use materialSwitch but to my knowledge there is nothing there I should be creating a custom binding for. Maybe that's not even the issue?

I load the following scripts in the tags$head

ui <- gridPage(

  useShinyjs(),
  
  tags$head(
    tags$link(rel = "stylesheet", type = "text/css", href = "styles.css"), 
    tags$script(src = "https://code.jquery.com/jquery-3.6.0.min.js"),
    tags$script(src = "https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"),  # Adjust path as necessary
    tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-accessibility/4.0.5/js/bootstrap-accessibility.min.js"),  # Adjust path as necessary
    tags$script(src = "scripts.js")  
  ),

Is there something basic I'm missing? I haven't used javascript with R before and am lost down the pit now. Have created tryCatch around every Highcharter chart but that doesn't seem to be returning any error to the console. What could this error be referring to?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.