B(ytes.js)

A lightweight Javascript library for DOM traversing and event binding
written in a fair amount of bytes


Project maintained by archan937 Theme designed by mattgraham

Why write Bytes.js?

This is probably one of the first questions which pops up. To put it in one sentence:

"I wanted a lean, mean, non-bloated, cross-browser compatible JS library useful for dealing with some of the most common tasks done when writing Javascript".

First of all, I'm a big fan of lightweight utility tools that do not have any dependencies. That is why I often check out vX.js when searching for a useful Javascript snippet. I don't want to use jQuery without thinking about it being too much for the job.

So with vX.js as starting point, I have written Bytes.js. A lightweight JS library written in a fair amount of bytes. It is 2501 bytes when uncompressed, 1643 bytes when minified and 856 bytes when minified and gzipped.

Tested with QUnit

Bytes.js is tested with QUnit and is currently compatible with the following browsers:

Please note that complex CSS selectors are only supported in browsers with querySelectorAll().
You can run the tests yourself by clicking right here.

Installation

Setting up Bytes.js is only a matter of adding a simple script include tag:

Usage

The following live examples are based on the following HTML code;

Find elements

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Closest element

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Event binding

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Etcetera

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.