Look into potentially having a workaround to get rid of the "useShinyjs()" function
Some hints here https://github.com/rstudio/shiny/issues/1424
this gets extra complicated because both UI and server functions need shinyjs to be loaded, and both of them need to know whether it has been loaded already. Doesn't look feasible now, will maybe revisit at a later time
Opening this issue to try thinking about it again.
The parameters passed to useShinyjs() can be converted into options(). Or can maybe use a recently added feature in shiny internals or look at sys.calls() to figure out if need to use Rmd or not.
Closing because this just seems to present too many problems without any proper solution. A few things that complicate it are the fact that the shinyjs code needs to be sometimes injected in the UI (when using hidden()/disabled()/any other UI functions) but usually in the server, and I want to make sure the code only gets injected once and not more, and the code needs to be injected properly when using Rmd or custom templates, and there's also the issue of extendShinyjs()
@alandipert @bborgesr It'd be nice to know if (1) there's any way within the UI to know whether or not a piece of code was already added earlier in the UI, and also (2) if there was a way for the server to know that a piece of code was already added to the UI
Just tagging you in case you can think of something, but I know I didn't describe the problem very well either so no worries if it's too vague
Re-opening once again, more than half a decade later, because I really do want this to happen. My biggest pet peeve with shinyjs from the very beginning was that users had to call an additional function, and unfortunately since then I've seen a lot of other packages copy my approach. My newer packages that are simpler no longer require a useX() call (for example shinyalert, shinyscreenshot, shinytip all removed it), but in shinyjs it is more complicated. I'm still trying :)