Shiny: Javascript enabled?



I would like to ask you if there is a quick way to check if javascript is enabled in a browser when accessing a shiny web app to make sure that users have the best experience?




I am fairly certain most, if not all, shiny applications will not work if JavaScript is disabled in the browser. Shiny's client-side logic for handling inputs, outputs, and sending values to the server is a combination of JavaScript and WebSockets. If JavaScript is disabled then shiny cannot startup the necessary server to client connection.

A possible solution is running your shiny application and a separate web server. This second server could serve an html page which includes an iframe holding your shiny application. So, in the case that JavaScript is disabled the static page still shows and you can alert the user as to why the nested shiny application is not rendering.


nteetor, thank you very much for the reply. Do you by chance know where I could find an example with the implemented solution that you have mentioned?


I'm sorry, I do not have any public examples. I think unfortunately even the private repos I have in mind do not fully explore this approach. Typically my group's clients do not require us to account for disabled JavaScript.

Below is a small example application showing how to serve up a page with an embedded shiny application. Within the HTML you can use a <noscript> tag to include a message for users who have disabled JavaScript, see here for more on the <noscript> tag.

This is something of a toy example. In practice I would probably use a non-R web server to serve up the static pages. I hope this helps.


  host = "", port = 8080,
  app = list(
    call = function(req) {
        status = 200,
        headers = list(
          `Content-Type` = "text/html"
        body = as.character(
            style = "margin: 2rem 0 0 2rem;",
            tags$noscript(                     # <- <noscript>
              style = "color: red;",
              "Sorry, it looks like you have JavaScript disabled.",
              "Many features of this site may not work as intended."
            tags$iframe(                       # <- <iframe>
              style = "width: 80vw; height: 80vh;",
              src = ""