I have mostly been working with React and trying out Svelte for a while, so I thought I would go back to vanilla JS and I really enjoyed it. It’s simple and feels so refreshing.
It can get old pretty fast when you have to do complex DOM manipulations, but if you are just making a few static pages with some interactivity, you really don’t need a full framework.
Indy said:
It can get old pretty fast when you have to do complex DOM manipulations, but if you are just making a few static pages with some interactivity, you really don’t need a full framework.
That’s not quite right. This might have been true five years ago, but since 2020, vanilla JavaScript and TypeScript have improved quite a lot. PS: I’m guessing you mean TypeScript when you say JavaScript. Types are amazing.
@Kiran
I am not sure where the disagreement is? Types are great, but that’s not the point here, right? Whether you’re using vanilla JS or TS, even the simplest logic tends to be more detailed than when you use a framework.
<div>
{showButton && <button>Click</button>}
</div>
versus
<div id="mustHaveSomeSelectorInOrderToAppendTo"></div>
if (showButton) {
const btnWrapper = document.getElementById("mustHaveSomeSelectorInOrderToAppendTo");
// can’t risk runtime errors
if (btnWrapper) {
const btn = document.createElement("button");
btn.textContent = "Click";
btnWrapper.appendChild(btn);
}
}
@Indy
I can see both perspectives.
I agree that many people only prefer vanilla JS for simpler projects. However, developers who usually work with frameworks should really take a look at how vanilla JS is today every couple of years. You wouldn’t write vanilla JS like your example, you would be using Web Components.
@Indy
You could just set it to display none, then it’s just one line of code without needing the if check.
@Indy
Yes, it is more detailed. But is that such a bad thing?
With small projects, everything works fine. But for larger projects, having HTML inside JavaScript can look really messy. That is why big companies suggest keeping HTML, CSS, and JavaScript separate and letting them do their own jobs.
Plus, the two code samples are quite different. To keep them equivalent, you can create a div and add the button to it. That’s 5 lines of code compared to 3 lines.
I am updating my website for 2025 and went back to the basics - HTML, CSS, and JavaScript with Vite. I feel that rush I had when I first started coding years ago.
I have built some small but very interactive projects without any libraries or frameworks. It worked, but it quickly turned into a bit of a headache because of how vanilla JS can be.
If what you’re doing is so simple that it can be completed with vanilla JS, then you really need to rethink your tool choices.
Wait until you have to do anything more than a hello world while working with a team and you’ll find out how messy vanilla JS can get after just two weeks.
I’ve had this discussion too many times here, usually about using some form of a framework or a minimal one. For anything significant, you either use well-known libraries or frameworks that are tested and documented, or you end up creating your own incomplete and buggy version. Or you just don’t use any abstraction and end up with a total mess.
I’ll never go back to JS from TS unless it’s something very simple.
Ari said:
I’ll never go back to JS from TS unless it’s something very simple.
That’s interesting. What does TS bring to basic or trivial projects?
Ari said:
I’ll never go back to JS from TS unless it’s something very simple.
That’s interesting. What does TS bring to basic or trivial projects?
Read his comment again.
Yes, there is nothing like making your own framework to deal with anything that is more than a simple app.
I know right? I love it!
You can also just use vanilla HTML, CSS, and JS with Svelte.
You can also take it a step further and just use esbuild. A few lines of bash can bundle each JS package or folder and copy them to dist. With browsers supporting dynamic imports, it’s really simple.
HMR is definitely one of the big perks Vite provides, but why would you need to refresh the page all the time? You’re basically just hitting ctrl-s instead of actually concentrating on the code and features you create. One of the best feelings in programming is writing a lot and having it work the first time.
Can someone remind me what vite is and why we should use it?
Ellis said:
Can someone remind me what vite is and why we should use it?
Or you could just look it up online.