Making websites with vanilla JavaScript in 2019?
We have a myriad of JavaScript frameworks these days - React, Vue, and Angular being some of the most prominent ones. Are there any front-end developer in HN using vanilla JS to make websites and if so, why are you not using the said frameworks? What's your experience of making website with vanilla JavaScript like these days?
11 comments
[ 3.5 ms ] story [ 33.5 ms ] threadSo as a developer, no I am not using vanilla js to answer your question because I work with interaction heavy web apps where I am better off with a well tested js framework. I don't have time (time is money) to try and do those interactions using plain js (I at least suck at plain js). One anecdote for you.
We recently upgraded our B2C website, which is a SPA/vue affair. After going through the development and upgrade of the site, and seeing first-hand what the code looks like after having to do some debugging in it, I will clearly keep the SPA/js hammer in the tool drawer unless I have a very specific nail to hit.
Our next project, which is a back-office/CRUD app, will be Django or flask with a sprinkling of vanilla js (maybe some jquery to make things easier) and plain, honest html. I expect the experience to be quite less eventful than building a SPA.
To answer the rest of the questions, some reasons for this: dev time per page seems higher with SPA (of course the fact that I talk about pages is a hint that SPA may not be the right fit); harder to reason about when what bit of page is displayed how; and cold sweats every time I look at the length of package.json (it may very well be that we don’t do things The Right Way, but The Right Way is easier with classical frameworks)
The current stack is dirt simple to debug and does the job. It’s also easy to hire people who can work on it and be productive right away. This ain’t rock star level coding.
In the end it’s hard for me to justify the investment in SPA/new framework.
Frameworks have advantages, but in a tiny team, separation of concerns is not a major problem. There's a bit of overhead in maintaining, debugging, and a large opportunity cost in learning. The whole "it's better to practice one kick a thousand times than practice a thousand kicks once".
In a sense, it feels much like drawing with an easy medium like pencil, instead of using oil. They're all good in their own way, but I like the raw feel of it, and it works just fine.
But you mention React, Vue, and Angular. Those are frameworks for single-page applications (SPA). So my advice there is not to make a SPA. Make a multi-page application instead. Someone wrote an article and called it the ROCA style, https://roca-style.org/
Basically you can still use JavaScript to show and hide things, but if the entire page is changing, I put that in a different file on the server.