DEV Community

Discussion on: Writing a .parents() function using Vanilla JS

Collapse
 
leob profile image
leob • Edited

Great article ...

All in all if you want pure DOM manipulation (not using React or Vue or whatever) then still nothing beats the jQuery API for elegance and conciseness.

Makes me wonder if there isn't something like a "jQuery lite" which wraps the Vanilla API and provides a small subset of the most useful/popular jQuery functions, but with a minimal bundle size (the full jQuery library is still surprisingly large) ... you've written part of it already.

Collapse
 
urielbitton profile image
Uriel Bitton

Thanks!

Youre right a jquery lite could be a good idea.

Collapse
 
leob profile image
leob • Edited

Something like that might even exist already, previously there was something called zepto.js ... it still "exists" but latest version is from 2016 (and nobody uses it anymore I think) ... then there's"jquery-lite" (github.com/deager/jquery-lite) which is 5 years old and very limited ... no those 2 aren't going to win the war.

"jQuery Slim" looks better, but still large ... then this one, "Cash":

github.com/fabiospampinato/cash

I think that's what we would be looking for - almost all of the stuff you need and want from jQuery (including "parent()", "closest()", "append()", "on()", "off()", you name it), but the download is 3 to 4 times smaller.

Next question is, does it perform equally well as jQuery ... if it downloads quicker but execution is sluggish then you haven't gained anything.

Thread Thread
 
urielbitton profile image
Uriel Bitton

interesting i'll have a look at these thanks.

But i'm anyways working on enhancing my vanilla js skills so im gonna try to get as good with JS as i am with jquery and i wont even think about the convenience jquery has in a few months :)

Collapse
 
gwutama profile image
Galuh Utama • Edited

Don’t forget that web servers will compress files before transferring to client (usually gzipped), which practically means that the size of a text file will be around 1/3 - 1/4 or even less than its original size.

Collapse
 
leob profile image
leob

Well yes that's always the case when server gzip is enabled, regardless the type of resource (JS, CSS) or whether you use jQuery or another library, but having a smaller bundle size is beneficial anyway. I was just a little bit surprised when looking at the bundle size of jQuery and realizing that it isn't really much smaller than more full-featured libs like React or Vue.