Small & fast DOM and event library for modern browsers.
Having the same familiar API as jQuery (but without the extra "weight" of modules like $.ajax
, $.animate
, and $.Deferred
), it works great stand-alone or paired up with e.g. Backbone or Angular.
The library is only 3-4KB (min+gzip), and it's easy to create a custom build to exclude parts you don't need.
The source is written using ES6 features, and transpiled to AMD and CommonJS with Traceur. Browserify is used to create a UMD bundle (supporting AMD, CommonJS, and fallback to browser global).
This library was recently renamed from "jQuery Evergreen".
- domtastic.min.js (auto-updating release in 0.7.x branch on jsDelivr CDN)
- API Docs
- Run tests
- Run benchmarks (results: class, constructor, DOM, selector)
- Coverage report
- Complexity report
# Install
npm install domtastic
# Use
var $ = require('domtastic');
# Install
bower install domtastic
# Configure
paths: {
'domtastic': 'bower_components/domtastic/domtastic'
}
# Use
define(['domtastic'], function($) {
$('.earth').addClass('evergreen').on('sunrise', '.people', awake);
});
# Configure
<script src="//cdn.jsdelivr.net/domtastic/latest/domtastic.min.js"></script>
# Use
$('.planet').addClass('evergreen').on('sunrise', '.grass', grow);
every
filter
forEach
indexOf
map
pop
push
reverse
shift
some
unshift
attr
removeAttr
addClass
removeClass
toggleClass
hasClass
after
append
before
clone
prepend
on
off
delegate (deprecated, will be removed soon)
undelegate (deprecated, will be removed soon)
trigger
triggerHandler
ready
html
noConflict
$
find
The pre-built "bare" package does not include the attr
, data
, and html
modules.
The pre-built "full" package also includes the following modules:
appendTo
empty
remove
replaceWith
text
val
isNative
native
children
contents
closest
eq
get
parent
slice
As mentioned in the introduction, DOMtastic doesn't have methods for your Ajax, Animation and Deferred needs. Please find your own libraries to fill in the gaps as needed. Here are just some examples:
- Ajax: microjs#ajax, rest.js
- Animation: microjs#animation, Move.js, Animate.css
- Deferred (aka promises): when.js, RSVP.js
However, feel free to open an issue if you feel an important method is missing.
Latest versions of Chrome, Firefox, Safari, Opera, Chrome Mobile iOS, and Mobile Safari. IE10 and IE11. IE9 only needs a polyfill for classList
to make these tests pass.
Run the benchmark suite to compare the performance of various methods of jQuery, Zepto and DOMtastic.
You can opt-in to work directly with Node
and live NodeList
objects, as opposed to the default, wrapped $
object.
git clone [email protected]:webpro/DOMtastic.git
cd DOMtastic
npm install
gulp --exclude=attr,mode,html
And find the output in the dist/
folder.
Run the test suite. You can also clone/fork the sources from Github and run tests locally.
Many thanks to these sources of inspiration:
Thanks to jsDelivr for hosting DOMtastic.