The README for Cash is straightforward:
Cash is an absurdly small jQuery alternative for modern browsers (IE11+) that provides jQuery-style syntax for manipulating the DOM. Utilizing modern browser features to minimize the codebase, developers can use the familiar chainable methods at a fraction of the file size. 100% feature parity with jQuery isn’t a goal, but Cash comes helpfully close, covering most day to day use cases.
6 KB minified and gzipped, which is even smaller than Zepto. Zepto’s whole point was a smaller jQuery, but it hasn’t been touched in a bunch of years, so there is that too.
I wonder how much smaller Cash would be if it dropped IE 11 support.
jQuery is still used on an absolute ton of sites, only just recently having peaked in usage and showing signs of decline. That must be because it comes on most WordPress sites, right?! That’s like 42% of all sites right there.
Anyway, if you tend to reach for jQuery just for some convenient APIs, Cash looks like a nice alternative. I don’t blame you either. Typing
$ instead of
document.querySelectorAll still feels good to me, not to mention all the other fanciness tucked behind that dollar sign function.
Also worth mentioning: if you’re looking to straight-up remove jQuery from a project, replace-jquery might be worth a look:
Automatically find jQuery methods from existing projects and generate vanilla js alternatives.
“..for modern browsers (IE11+)…”
You keep using that word. I do not think it means what you think it means.
Cash’s maintainer here. There’s almost no IE11-specific code in the codebase, so you might as well mention that IE11 is supported in a library like this.
Mine is .6kb https://github.com/argyleink/blingblingjs
I wish JS just offered aliases for long method names, like document.qs, document.qsa, etc. — can you imagine how many billions of bytes of code that would save worldwide? But this is actually even better — even smaller and adds array methods. Thanks!
Cash’s maintainer here. I think the answer to that is “very little”, maybe even less than 1%, there’s very little IE11-specific code already.
It could get a bit smaller by reorganizing how methods are attached to the prototype though, maybe.
Would it be possible to drop in Cash as a replacement on a default WordPress install?
That would depend on your setup. If you use a bundler like Webpack, it’s as easy as inserting “import $ from ‘cash-dom'” at the top of your JS file and getting to work. Webpack will change the $ to ‘cash_dom__WEBPACK_IMPORTED_MODULE_5___default’ or something similar in your bundled JS file, so there’s no risk of it clashing with jQuery at all.