Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

VanillaJS is a worse solution. When the JS framework benchmark first came out, VanillaJS was the fastest. After some of the vdom frameworks came out (especially InfernoJS), VanillaJS was slower.

How did they make VanillaJS faster? They studied the output code paths of InfernoJS and copied them. Each time InfernoJS would release new, faster versions, they'd backport those optimizations into the VanillaJS. Then SolidJS and Svelte came out and it copied them.

By the time it was done, the VanillaJS code was fast, but not very readable and definitely NOT the type of code a human would write. Additionally, each new piece being hand-written means each is a brand new chance to miss little implementation details that lead to subtle bugs and memory leaks. As your site grows, you'll also develop bugs from accidentally stomping on someone else's piece of the DOM unless you add all the overhead/complexity of shadow DOM.

pReact (or something similar if it exists) is a much better type of solution IMO. Here's a link to the whole source code minified.

https://esm.sh/preact@10.26.4/es2022/preact.mjs

It's not even a whole page on my laptop screen, but it will be faster than an average dev's VanillaJS code 95% of the time. It won't have those potential implementation bugs. It will scale to many components and devs effortlessly. It also provides clean, tested ways to add other features your project may need in safe ways.



You have to define "worse". What is actually "worse" is paying developer time to sit there in a never-ending upgrade and deprecation cycle when your core product is elsewhere.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: