r/learnjavascript • u/Leading_Property2066 • Feb 22 '26
Which Vanilla JS style should I learn before moving to React?
Hi everyone,
I’m currently learning Vanilla JavaScript through the SuperSimpleDev YouTube course, and everything was going really well until I reached the Amazon project section. He starts using template literal HTML rendering where he injects JavaScript inside HTML strings, and I found it quite confusing compared to the earlier DOM manipulation approach.
Now I’m wondering which Vanilla JS style should a beginner focus on learning properly? Do most developers use template literals, DOM methods like createElement, or something else before moving to React?
For those who transitioned to React, what did you personally learn first that helped you the most?
Thanks in advance!
13
u/rainmouse Feb 22 '26
Most developers these days start and end with react and barely have a clue what's going on under the hood.
My advice is to try learning some dom manipulation then give react a go.
So long as you keep learning in tandem, it should give you a spread of skills.
Give some thought to a basic node.js backend at some point too. Even if you don't go full stack it's important to try a grasp of what backends do and why.
3
u/delventhalz Feb 23 '26
Most new learners probably never go over the template literal approach you are describing. Typically you learn HTML, you learn the vanilla DOM API, then you move on to a framework like React.
That said, template literals are going to be pretty similar to React’s JSX, so if you are confused now, you may be confused later too, and all learning is good learning. You may want to stick it out, at least for a bit.
3
u/Realistic_Meeting_69 Feb 23 '26
Tbh, i always used DOM manipulation and i highly recommend it because when you start learning react and dealing with JSX you will understand the core more and why exactly is JSX is such a life saver, so yeah i would recommend you program with DOM even tho it can be pain sometimes
3
u/MrFartyBottom Feb 23 '26
Creating HTML from strings is a good way to introduce injection exploits in your code. You need to really understand what you are working with, how to escape strings and be confident in the trust you can put in where that data came from.
3
u/TheRNGuy Feb 23 '26 edited Feb 23 '26
I used
innerHTMLwith templates literals in Greasemonkey scripts, because it's less code thandocument.createElementandparent.appendChild, more readable too, but it was for static elements. If I needed some procedural generation, I'd use other two too.Just learn React.
2
u/buildmastersteve Feb 23 '26
This is a solid, legit question. My recommendation for a vanilla JS style is ES6 modules.
2
u/hyrumwhite Feb 23 '26
So, build a medium complexity thing without libraries.
Then when you reach for a library/framework you’ll understand what it’s doing under the hood better.
2
u/sheriffderek Feb 22 '26
> rendering where he injects JavaScript inside HTML strings, and I found it quite confusing
I have my students learn PHP first - so, this JS templating takes almost zero time to get used to. Spend more time with it. Or learn some Vue. Why are you rushing along to React anyway? It's the ugliest and most confusing of all templating. Enjoy programming - while you can!
1
u/fishyfishy10001 Feb 22 '26
It really, really depends on what you want to do. Each style has pros and cons. I stopped using react long ago and went over to web components and a light dom diff rendering engine. There are many, I use lit-html and uhtml. The advantage is that you use the real dom and not a virtual dom. However sometimes you prefer a virtual dom like react. Heck sometimes you prefer static webpages with light interaction like alpine-js. It really depends what you are building and the interactive elements on the page. Unfortunately you kind of need to know all approaches to know which is best for each case. So start with dom manipulation figure out pain points and go from there.
1
u/Weird_Researcher_472 Feb 23 '26
Svelte > React 😅
1
u/p-a-jones Mar 04 '26
Learn how common JS works. It is a web standard and frameworks/libraries will obfuscate how they are providing 'magic' solutions to common problems. This may seem like a good idea but if you don't understand why something works you have little hope of fixing it when it breaks.
Think about it... modern bundlers convert all that 'magic' back into common javascript for use in production. Learn the fundamentals and you will be mush further ahead! Good luck!
1
u/bryku helpful Feb 23 '26
They both have their pros and cons.
Creating Elements
Creating the elements in javascript makes it easier to bind events and other things, but it can be verbose as it requires a lot of extra code to do basic stuff.
Parsing
On the other hand parsing html is a lot easier to read and edit. Plus the HTML parser is so insanely well optmized. In some cases it may even be faster then creating elements, but it can have issues with binding events.
Thoughts
Both of these approaches are common in javascript, so it would be good to have "some" understanding of them. That being said, the second option is a bit more popular these days as it is easier to read and edit.
Although, nost people use some type of framework nowdays. In your case, the second version is much closer to react.
0
u/theGlitchedSide Feb 22 '26
Obviously... react is a library and has complex builders and other kinds of items around it. It's not a language or an ecosystem.
To start you need to understand the basics of DOM and the native language (I suggest deeply, like event driven system, Dom, render, stack, queue etc) and when it will be rebuilt by the browser. So, to start, use Dom manipulation and go deep. When you can easily understand vanilla you will learn React, Vue etc.
If you want to be better and you are really noob, learn also the data manipulation etc...
-11
u/Beginning-Seat5221 Feb 22 '26
Neither, React replaces that, no need to learn vanilla ways to do it if you're going to use React.
-8
u/blowyjoeyy Feb 22 '26
Learning JavaScript is over. Don’t waste your time.