Umbrella JS

Lightweight javascript library for DOM manipulation and events

README

Umbrella JS test badge stats License MIT


[Library Documentation](http://umbrellajs.com/documentation) | [Migrating from jQuery guide](https://github.com/franciscop/umbrella/blob/master/jquery.md)


Covers your javascript needs for those rainy days. A <3kb performant jQuery-like library born from the question: You might not need jQuery, then what do you need?

You probably need awesome CSS (like Picnic CSS) and a lightweight, modern and performant javascript library. This does:

- DOM traversal (selector, filter, find, each, etc.)
- DOM editing (classes & attributes, html, before, etc.)
- Event handling

A couple of simple examples:

  1. ``` js
  2. // Simple events like jQuery
  3. u("button").on('click', e => {
  4.   alert("Hello world");
  5. });

  6. // Handle form submissions
  7. u('form.login').handle('submit', async e => {
  8.   const user = await fetch('/login', {
  9.     method: 'POST', body: new FormData(e.target)
  10.   }).then(res => res.json());
  11.   window.href = '/user/' + user.id;
  12. });
  13. ```


Getting started


There are few ways to use Umbrella JS:


Play with it


Instead of installing it, you can just play with it in JSFiddle:

[Try on JSFiddle](https://jsfiddle.net/franciscop/mwpcqddj/)


Use a CDN


jsdelivr.com is an awesome OSS service that hosts many open source projects so you don't need to even download the code:

  1. ``` js
  2. <script src="https://cdn.jsdelivr.net/npm/umbrellajs"></script>
  3. ```


Install with npm


Using npm is a front-end package manager that makes it super-easy to add a new package:

  1. ```
  2. npm install umbrellajs
  3. ```


Module support


If you use a front-end module bundler like Webpack or Browserify, u is exposed as CommonJS exports. You can pull them in like so:

  1. ``` js
  2. // ES Modules/Webpack/etc
  3. import u from 'umbrellajs';

  4. // Commonjs
  5. var u = require('umbrellajs');
  6. ```

ES Module support


If you use an ES Module, u and ajax are exposed as ES Module exports.
You can pull them in like so:

  1. ```
  2. import u from 'umbrellajs/umbrella.esm.js'
  3. ```

Download it


If you like it or prefer to try it locally, just download umbrella.min.js:

[Download Umbrella JS](https://raw.githubusercontent.com/franciscop/umbrella/master/umbrella.min.js)

Add it to your project:

  1. ``` html
  2. <script src="umbrella.min.js"></script>
  3. ```



Support: IE11+


Current usage for IE 10- is under 1% for each version (8, 9, 10) so it's not Umbrella's mission to support this. However, those extra seconds gained from loading faster on mobile might be even bigger than that percentage. You should probably test it.

Known, wontfix IE10- bugs:

- Invalid target element for this operation when trying to use any of these methods ontable, tbody, thead or tr. Check the issue on StackOverflow. For those elements, this gives an error:
  - .before()
  - .after()
  - .append()
  - .prepend()


- Unable to get property ____ of undefined or null reference since classList is not supported by IE9-. Just usepolyfill.js and they will work. Affects:
  - .addClass()
  - .removeClass()
  - .hasClass()
  - .toggleClass()

- Choosing multiple options within `