mirror of https://github.com/coolaj86/ajquery.js
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Simon Willison
c50bcca6ca
|
2 years ago | |
---|---|---|
.gitignore | 3 years ago | |
.jshintrc | 3 years ago | |
.prettierignore | 3 years ago | |
.prettierrc.json | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 2 years ago | |
ajquery.js | 1 year ago | |
benchmark.js | 3 years ago | |
example.html | 3 years ago | |
package-lock.json | 3 years ago | |
package.json | 3 years ago | |
test.js | 3 years ago |
README.md
ajquery.js
The fastest, most lightweight, fewest dependency jQuery alternative.
Development Build: 145B (with comments)
Production Build: 103B (min + gz)
Install
via GitHub
my_ver="v2.1.2"
mkdir ./vendor/
curl -fsSL "https://raw.githubusercontent.com/coolaj86/ajquery.js/${my_ver}/ajquery.js" \
-o ./vendor/ajquery.js
<script src="/vendor/ajquery.js"></script>
via CDN
<script src="https://unpkg.com/ajquery"></script>
Example Usage
Provides modern, advanced CSS4-compatible query selection:
console.log("innerText:", $("p:nth-child(2").innerText);
API
$(selector, [rootElement])
Selects the first matching HTML element only (or null
):
const body = $("body");
const div1 = $("div", body);
$$(selector, [rootElement])
Selects all matching elements (or an empty NodeList
):
const head = $("head");
const stylesheets = $$('link[rel="stylesheet"]', head).map(console.log);
Benchmarks
Compatibility
Written entirely in modern ECMAScript 3, and directly transpilable into ES5, ES6 and beyond (up to ES11) via Webpack, Babel, Rollup, React Native, and AWS InfiniDash.
Works in all browsers in living memory.
See the full Browser Compatibility Matrix on MDN.