Provides integration with Cash, an absurdly small jQuery alternative for modern browsers (IE9+).
Cash is a small library for modern browsers (Chrome, Firefox, Safari and Internet Explorer 9+) 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.
| Library | Cash | jQuery 3.0 | jQuery 2.2 |
|---|---|---|---|
| Uncompressed | 20K | 263K | 253K |
| Minified | 9.8K | 86K | 76K |
| Minified & Gzipped | 3.5K | 34K | 30K |
If you need to support old browsers (IE8 below), Cash is not for you.
Requirements
Cash library:
Download Cash and extract it as is, rename cash-master to cash, so the
assets are at any:
- /libraries/cash/dist/cash.min.js or
- /libraries/cash-dom/dist/cash.min.js
Both paths are supported. The first is if downloaded directly from Github. The latter if using Composer via asset-packages and or via `npm-asset`. Or any path supported by core library finder or libraries.module.
Installation
Install the module as usual, more info can be found Installing Drupal module.
Related core issues
With the removal of jQuery from Core starting in Drupal 9, there are some discussions about DX and smaller alternatives to jQuery in Drupal core. Cash is one candidate, so we're tracking the issues here:
- #3052002: [meta] Replace JQuery with vanilla Javascript in core
- #3176441: JavaScript event handling without a full jQuery dependency
Please create an issue should you find further related core issues to link here.
Configuration
Visit the following to configure and make use of Cash:
/admin/config/media/cash
Migration guide from jQuery
If you're migrating from jQuery, be sure to read our migration guide.
Usage
The module doesn't do anything on its own by default.
Include it as needed using regular library attachments, e.g.:
$page['#attached']['library'][] = 'cash/cash';
Or use the provided UI for convenient at:
/admin/config/media/cash
Or use it as your own library dependency, recommended:
my_library:
js:
js/my_theme.min.js: {}
dependencies:
- cash/cash
Use it like `jQuery`, only now replace `jQuery` with `Cash`. Keep the `$` dollar sign as usual. No need to change it.
Who is this module for?
For anyone or modules working extensively with vanilla JavaScript rather than jQuery.
Project information
- Project categories: Developer tools, Integrations, Performance
- Created by gausarts on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
