Making websites with vanilla JavaScript in 2019?

16 points by roi1672 ↗ HN
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 ] thread
It depends on what kind of websites are you talking about. If it is more of a web application with heavy interactions on the page, you are probably better off using a js framework or you will end up writing your own in some ways. But if you are talking about web pages with javascript to do a few fetches here and there, you can surely use vanilla js.

So 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.

(CTO, not front-end dev so will answer more on philosophy and strategy than nuts & bolts)

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)

We have a back office/CRUD app written in html, bootstrap and thymeleaf (serverside templates). There is also a bit of Jquery when needed.

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.

If you don't need to do much, then why not? If you are sprinkling validation, maybe a notification or two, and can assume modern browsers then vanilla is good. Although I'd still use Typescript and Webpack.
Typescript can bundle and minify now, is there really a need for webpack for a small website? Even if you're using it for sass or something, just run the sass builder separate and include the generated css on page. Webpack seems like overkill in a small site like this.
I'll have to give that a try again. Last time I ran into some problem. Might be due to limitations on which module system you can use.
It's not exactly vanilla, but my favorite stack is still jQuery and Bootstrap. It's easy and fun to make things with.

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.

I see lots of sites/apps still being built with Rails/Laravel and just a little javascript + jQuery on the front end as needed.
I did look into using one or more JavaScript frameworks before I created CloudBuddy (https://cloudbuddy.cloud/), but decided against it. Since I was new to JavaScript at the time, I figured that learning a framework would be more work than just coding the JavaScript directly. In hindsight, I think it was the right decision since maintenance has been straightforward. If you have questions and would like to chat with someone that's been through it, my contact info is in my profile.
First of all, vanilla JavaScript is far easier with IE 11 or Edge (and was always easy with Firefox and Chrome). But it was jQuery that I used before. That's what I would contrast with vanilla JavaScript.

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.

I routinely inspect the source of popular websites and rarely see React being used. The bulk of React coding is just tech bloggers showing off to their coder pals and otherwise trying to impress each other. jQuery however is everywhere but apparently 'dying out' and being replaced with Vue (which again is a rarity to see in the wild).