For this type of scripts move to single page applications is definitely a good thing – now we get at least partially maintainable application, with proper module importing, and with new shiny frameworks which allow to handle complex interactions, routes, shared data across screens, reusing UI elements across applications (!) or even across the whole web (as open-source components). However, this article is not about them – I already complained about SPA being a default choice nowadays for literally everything; this article is about small websites.
Before this niche was dominated by jQuery and its huge ecosystem of plugins, with all sorts of sliders, image galleries and rich animations. Also, it was super simple to integrate it, usually just initializing some plugin with parameters (or even with defaults) and providing an element id. Everything else often was specified in the markup (or it required certain markup rules), and HTML, being a declarative language, was simple enough to figure it out. In fact, jQuery was so big that people really wondered why not to include it in browsers by default. jQuery also had a lot of convenient functionality included (one might call it “missing” stdlib for DOM), which made making simple interactions super simple.
Nowadays some libraries still pack UMD build, which is essentially a global variable version of loading libraries, but a lot of them don’t. Also, there are much more frameworks out there now, and all these widgets are only framework-specific, and not only require to use them (for jQuery plugins you needed the library as well), but often you need to make the whole page using that framework!
The last part is the worst one, I think. All these tutorials out there will suggest to add some advanced data management library, refactoring code in some special, “more declarative” way (think how often somebody tried to convince to refactor your HTML), and some people will follow that! Now, this advice is good, but probably only for big applications, and not for a small GatsbyJS website, which would be a perfect folder with 5
.html files. Yes, you would not be able to reuse this menu, but you can just copy it (and CSS classes make it sort of reusable).
Maybe I am wrong, and it is not that bad. But using internet, reading blogs, looking at landing pages I feel that these small websites, previously accessible to everyone with HTML knowledge and minimal JS skills are slowly going away, now more and more often replaced with more “scalable” applications.