A library of useful polyfills to ease working with HTML5 in legacy environments.
This include can be added to the header or placed inline before the script is invoked.
<script src="js/polyfills.js"></script>
Or use Require.js.
requirejs([
'js/polyfills.js'
], function(polyfills) {
...
});
Or import into an MVC framework.
var polyfills = require('js/polyfills.js');
polyfills.html5();
Add support for HTML5 elements in Internet Explorer 8 and lower.
polyfills.arrayIndexOf();
Adds support for array.indexOf.
polyfills.querySelectorAll();
Adds support for document.querySelectorAll (1).
polyfills.addEventListener();
Adds support for element.addEventListener, element.removeEventListener and element.dispatchEvent (2).
polyfills.consoleLog();
Adds support for console.log.
polyfills.objectCreate();
Adds support for object.create (3).
polyfills.stringTrim();
Adds support for string.trim, string.ltrim, string.rtrim and string.fulltrim (4).
polyfills.localStorage();
Adds support for localStorage.getItem, localStorage.key, localStorage.setItem, localStorage.length, localStorage.removeItem (5).
This project uses node.js from http://nodejs.org/
This project uses gulp.js from http://gulpjs.com/
The following commands are available for development:
npm install
- Installs the prerequisites.gulp import
- Re-imports libraries from supporting projects to./src/libs/
if available under the same folder tree.gulp dev
- Builds the project for development purposes.gulp dist
- Builds the project for deployment purposes.gulp watch
- Continuously recompiles updated files during development sessions.gulp serve
- Serves the project on a temporary web server at http://localhost:8500/.gulp php
- Serves the project on a temporary php server at http://localhost:8500/.
- Connolley, Paul. "IE7 querySelectorAll polyfill", https://gist.github.com/connrs/2724353
- Neal, Jonathan. "Polyfill the EventListener interface in IE8", https://gist.github.com/jonathantneal/3748027
- Gasparini, Ryan. "HTML5 API Polyfills", https://gist.github.com/rxgx/1597825
- Perelman, Eli. "String.prototype.trim polyfill for 140byt.es", https://gist.github.com/eliperelman/1035982
- Mozilla Developer Network. "DOM Storage guide", https://developer.mozilla.org/en/docs/Web/Guide/API/DOM/Storage
This work is licensed under a MIT License. The latest version of this and other scripts by the same author can be found on Github and at WoollyMittens.nl.