Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cash

> 编程语言
Open source

An absurdly small jQuery alternative for modern browsers.

7.0K stars0 likes1 views
WebsiteGitHub

About

An absurdly small jQuery alternative for modern browsers.

Cash

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.

Comparison

Size Cash Zepto 1.2.0 jQuery Slim 3.4.1
Unminified 36.5 KB 58.7 KB 227 KB
Minified 16 KB 26 KB 71 KB
Minified & Gzipped 6 KB 9.8 KB 24.4 KB

A 76.6% gain in size reduction compared to jQuery Slim. If you need a smaller bundle, we support partial builds too.

Features Cash Zepto 1.2.0 jQuery Slim 3.4.1
Supports Older Browsers ❌ ️❌ ✔
Supports Modern Browsers ✔ ️✔ ✔
Actively Maintained ✔ ❌ ✔
Namespaced Events ✔ ️❌ ✔
Typed Codebase ✔ (TypeScript) ️❌ ❌
TypeScript Types ✔ (generated from code) ⚠️ (via DefinitelyTyped) ⚠️ (via DefinitelyTyped)
Partial Builds ✔ (can exclude individual methods) ⚠️ (can exclude whole modules) ⚠️ (can exclude whole modules)

If you're migrating from jQuery be sure to read our migration guide.

Usage

You can get Cash from jsDelivr and use it like this:

xml
<script src="https://cdn.jsdelivr.net/npm/cash-dom/dist/cash.min.js"></script>
<script>
  $(function () {
    $('html').addClass ( 'dom-loaded' );
    $('<footer>Appended with Cash</footer>').appendTo ( document.body );
  });
</script>

Cash is also available through npm as the cash-dom package:

bash
npm install --save cash-dom

That you can then use like this:

javascript
import $ from "cash-dom";

$(function () {
  $('html').addClass ( 'dom-loaded' );
  $('<footer>Appended with Cash</footer>').appendTo ( document.body );
});

Documentation

Cash gives you a query selector, collection methods and some library methods. If you need more details about our API just check out jQuery's, while we don't implement everything that jQuery provides, pretty much everything that we do implement should be compatible with jQuery. Cash can be extended with custom methods, read how here.

$()

This is the main selector method for Cash. It returns an actionable collection of nodes.

If a function is provided, the function will be run once the DOM is ready.

javascript
$( selector [, element] ) // => collection, using `element` as the context
$( selector [, collection] ) // => collection, using `collection` as the context
$(node) // => collection
$(nodeList) // => collection
$(htmlString) // => collection
$(collection) // => self
$(function () {}) // => document ready callback

Collection Methods

These methods from the collection prototype ($.fn) are available once you create a collection with $() and are called like so:

javascript
$(element).addClass ( className ) // => collection

Some extra methods are available but disabled by default.

Attributes Collection CSS Data Dimensions Effects
fn.addClass () fn.add () fn.css () fn.data () fn.height () fn.hide ()
fn.attr () fn.each () fn.innerHeight () fn.show ()
fn.hasClass () fn.eq () fn.innerWidth () fn.toggle ()
fn.prop () fn.filter () fn.outerHeight ()
fn.removeAttr () fn.first () fn.outerWidth ()
fn.removeClass () fn.get () fn.width ()
fn.removeProp () fn.index ()
fn.toggleClass () fn.last ()
fn.map ()
fn.slice ()
Events Forms Manipulation Offset Traversal
fn.off () fn.serialize () fn.after () fn.offset () fn.children ()
fn.on () fn.val () fn.append () fn.offsetParent () fn.closest ()
fn.one () fn.appendTo () fn.position () fn.contents ()
fn.ready () fn.before () fn.find ()
fn.trigger () fn.clone () fn.has ()
fn.detach () fn.is ()
fn.empty () fn.next ()
fn.html () fn.nextAll ()
fn.insertAfter () fn.nextUntil ()
fn.insertBefore () fn.not ()
fn.prepend () fn.parent ()
fn.prependTo () fn.parents ()
fn.remove () fn.parentsUntil ()
fn.replaceAll () fn.prev ()
fn.replaceWith () fn.prevAll ()
fn.text () fn.prevUntil ()
fn.unwrap () fn.siblings ()
fn.wrap ()
fn.wrapAll ()
fn.wrapInner ()

$.fn

The main prototype for collections, allowing you to extend Cash with plugins by adding methods to all collections.

javascript
$.fn // => Cash.prototype
$.fn.myMethod = function () {}; // Custom method added to all collections
$.fn.extend ( object ); // Add multiple methods to the prototype

fn.add ()

Returns a new collection with the element(s) added to the end.

javascript
$(element).add ( element ) // => collection
$(element).add ( selector ) // => collection
$(element).add ( collection ) // => collection

fn.addClass ()

Adds the className class to each element in the collection.

Accepts space-separated className for adding multiple classes.

javascript
$(element).addClass ( className ) // => collection

fn.after ()

Inserts content or elements after the collection.

javascript
$(element).after ( element ) // => collection
$(element).after ( htmlString ) // => collection
$(element).after ( content [, content] ) // => collection

fn.append ()

Appends content or elements to each element in the collection.

javascript
$(element).append ( element ) // => collection
$(element).append ( htmlString ) //

Issues· 16 open

View all issuesOpen on GitHub
  • #437

    Is cash.js still maintained?

    Updated May 30, 2026
  • #435

    Improve TypeScript support for element creation in Cash-dom

    Updated Jan 4, 2025
  • #432

    kenwheeler.github.io/cash is out of date but still exist

    Updated Aug 19, 2024
  • #412

    Drop IE11 support

    enhancementUpdated Nov 3, 2023
  • #373

    Support for scroll methods

    enhancementhelp wantedUpdated Sep 27, 2023
  • #380

    Augmenting Cash with my own functions

    bughelp wantedUpdated Apr 13, 2023
  • #338

    Documentation website

    enhancementhelp wantedUpdated Feb 13, 2023
  • #396

    Support undoing CSS transforms when measuring dimensions

    enhancementUpdated Nov 15, 2022
  • #363

    Ensuring `$.fn.submit` is aligned with jQuery

    bugUpdated Apr 22, 2021
  • #331

    Passive listeners

    enhancementUpdated Sep 13, 2020

> Tags

JavaScriptcashdomjavascriptjquery

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 22, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言