From https://shiny.rstudio.com/articles/packaging-javascript.html :
(One caveat for runtime: shiny apps, regardless of which option you choose: your Rmd is not rendered until well after the browser page has loaded, so you can’t rely on the DOMContentLoaded event, or its jQuery equivalent, $(document).ready() .)
In an Rmarkdown with runtime: shiny I have also tried
$(document).on('shiny:connected', function(event) { alert('shiny:connected 2'); Shiny.onInputChange('shinyconnected2', 2); });
Whether putting this in tags$head(tags$script(...)) or a {js} chunk, it doesn't work.
(In a shiny app, it works fine.)
My question: how to detect the readiness of the shiny runtime in Rmarkdown?