Javascript ... which one?

by Andy Prevost

Sunday March 31 2024

To support a CSS framework requires some Javascript code. There is absolutely no doubt that about.

It's easy to verify that, just try the responsiveness of any CSS Framework based website without Javascript and it fails. For the menu to work in narrower viewpoints, you have to display some sort of "burger" and hide the horizontal menu. Click the burger and the horizontal menu morphs into a vertical menu (until closed). What makes that work? Javascript.

In my implementation of Bulma CSS framework, I've used both plain Javascript and JQuery. I actually prefer JQuery. But, it's also bloated and out of date. JQuery minified is about 80Kb and JQuery Slim minified is about 65Kb ... not a lot of difference, but I always go with the smaller size where possible. A caveat ... JQuery Slim does not support Ajax, effect, and all deprecated code is removed.

JQuery is catching up, though. In the search for some improvements and smaller footprint, I tried two other alternatives. Cash.js and Zepto.js. Both claim to be nearly identical in syntax – means no learning curve to me. I also must add that both Cash.js and Zepto.js are available through CDN. 

Of the two, Cash.js is the most actively updated and maintained. It is the smallest too at 8Kb – to gain that small size, it is also the less complete of the two alternatives. I ran into problems with the Windows.Scroll event and the ScrollTop event.

Zepto.js is a bit more than three times the size of Cash.js ... at 26Kb minified. That is still less than 1/3 the size of JQuery Slim ... and has about the same functionality and syntax. Looks like Zepto.js is going to be the one going forward. 

I must point out ... Zepto.js has not be updated in seven years. That's a bit concerning. To that end, I'll keep looking for a more up-to-date library.

And, an update: had to drop Zepto.js, too many incompatibilities. So, back to JQuery Slim minified version. 

 

◀ Previous Next ▶

Post a Comment