While a small script of 300 lines of code will do the job, a large script of 10,000 lines quickly becomes unmanageable. It’s the same problem one faces when writing R code.
While this works for the smaller projects, it is bound to lead to headaches for the larger ones. Thus far, all of the JavaScript code written in this book was placed directly in the file that was imported in the front end, be it htmlwidgets or Shiny-related code.