PlainJS essential functions. Because PlainJS is a useful set of common functions that are short simple wrappers around Vanilla JS which are as fast as JavaScript gets.
| Function | Example | Docs | Speed | Support | Polyfill |
|---|---|---|---|---|---|
| Elements By Tag | el=pj.tag('tag') |
Docs | Vanilla JS | getElementsByTagName DOM Core Level 2 |
Unneeded |
| Element By Id | el=pj.id('id') |
Docs | Vanilla JS | getElementById DOM Core Level 2 |
Unneeded |
| Element By Id | el=pj('id') |
Docs | Minimal convenience function | getElementById DOM Core Level 2 |
|
| CSS selector | el=pj.$('div.a') |
Docs | Vanilla JS | querySelectorAll IE>8, FF>3.4, Chrome>2, Safari>3.1, Android>2.0... |
Polyfill |
| Elements By Class | el=pj.class('class') |
Docs | Vanilla JS | getElementsByClassName IE>8, FF>2, Chrome>2, Safari>3.0, Android>2.0... |
Polyfill |
| Create Element | el=pj.create('tag') |
Docs | Vanilla JS | createElement DOM Core Level 2 |
Unneeded |
| Get Attribute | val=pj.get(el,'attr') |
Docs | Minimal convenience function | getAttribute DOM Core Level 2 |
Unneeded |
| Set Attribute | val=pj.set(el,'attr',value) |
Docs | Minimal convenience function | setAttribute DOM Core Level 2 |
Unneeded |
| Set Attributes | pj.setAll(el, obj) |
Minimal convenience function | setAttribute DOM Core Level 2 |
Unneeded | |
| Delete Attribute | val=pj.del(el,'attr') |
Docs | Minimal convenience function | removeAttribute DOM Core Level 2 |
Unneeded |
| Iterate over object | pj.each(obj,function(k,v){}) |
DOM Core Level 2 | Unneeded | ||
| Apply Property Values | pj.apply(el, obj) |
Minimal convenience function | DOM Core Level 2 | Unneeded | |
| Apply CSS Values | pj.css(el, obj) |
Docs | Convenience function | DOM Core Level 2 | Unneeded |
| Show Element | pj.show(el) |
Docs | Convenience | DOM Core Level 2 | Unneeded |
| Hide Element | pj.hide(el) |
Docs | Convenience | DOM Core Level 2 | Unneeded |
| Load JavaScript | pj.js('url', function loaded(){}) |
Convenience function | Same support as Google Analytics | Unneeded | |
| Random | pj.rnd() |
Vanilla JS | Math.random DOM Core Level 2 |
Unneeded | |
| CORS Request | pj.cors('url, function(data){}') |
Docs | |||
| JSONP | pj.jsonp('url?callback=fnName') |
Docs | Vanilla JS | DOM Core Level 2 | Unneeded |
| JSOND | pj.jsond('url', function(data) {}) |
CORS like data using JSONP | DOM Core Level 2 | Unneeded | |
| Load CSS | pj.getCss('url', function loaded(){}) |
Convenience | DOM Core Level 2 | Unneeded | |
| POST | pj.post('url', data, ) |
Docs | Convenience | DOM Core Level 2 | Unneeded |