{"id":13438053,"url":"https://github.com/inexorabletash/polyfill","last_synced_at":"2025-10-22T21:28:14.260Z","repository":{"id":8362724,"uuid":"9928100","full_name":"inexorabletash/polyfill","owner":"inexorabletash","description":"JavaScript Polyfills, Shims and More","archived":true,"fork":false,"pushed_at":"2021-08-13T20:46:50.000Z","size":1809,"stargazers_count":1355,"open_issues_count":18,"forks_count":356,"subscribers_count":51,"default_branch":"master","last_synced_at":"2024-04-26T15:02:45.777Z","etag":null,"topics":["javascript","polyfills"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inexorabletash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-08T04:10:29.000Z","updated_at":"2024-04-21T21:55:22.000Z","dependencies_parsed_at":"2022-08-24T16:01:59.012Z","dependency_job_id":null,"html_url":"https://github.com/inexorabletash/polyfill","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inexorabletash%2Fpolyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inexorabletash%2Fpolyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inexorabletash%2Fpolyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inexorabletash%2Fpolyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inexorabletash","download_url":"https://codeload.github.com/inexorabletash/polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221489234,"owners_count":16831396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","polyfills"],"created_at":"2024-07-31T03:01:02.565Z","updated_at":"2025-10-22T21:28:08.937Z","avatar_url":"https://github.com/inexorabletash.png","language":"JavaScript","funding_links":[],"categories":["Plugins","JavaScript","Polyfill"],"sub_categories":["Polyfills","React Components"],"readme":"polyfill - JavaScript and Web Polyfills\n=======================================\n\nThis is a collection of polyfills covering web platform features, from those defined as part of the ECMAScript standard to new web browser functionality. Most are for features shipping in major browsers. A few are experimental and called out as such, subject to change at any time.\n\nMy philosophy is that it's better to write future-looking code that takes advantage of new Web platform APIs where possible, and fill in the gaps with polyfills. There is no effort to produce 100% compliant behavior, or to completely hide differences in browser behavior.\n\nI use these in various pages on my sites; most are by me, or I have at least tweaked them. A more comprehensive list of polyfills can be found at [The All-In-One Entirely-Not-Alphabetical No-Bullshit Guide to HTML5 Fallbacks](https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills) by Paul Irish.\n\n### Getting the Code ###\n\nYou're already here! Great, just download it, or use:\n\n[git](https://git-scm.com/): `git clone https://github.com/inexorabletash/polyfill.git`\n\n[bower](http://bower.io/): `bower install js-polyfills`\n\n[npm](https://www.npmjs.com/): `npm install js-polyfills`\n\n\u003e It is *not* packaged as Node.js module(s); there's nothing to `require()`, this is just for distribution.\n\nOr just include scripts directly in your page via CDN (c/o [RawGit](https://rawgit.com/)):\n\n    \u003cscript src=\"https://cdn.rawgit.com/inexorabletash/polyfill/$TAGNAME/polyfill.min.js\"\u003e\u003c/script\u003e\n\n(look at [Releases](https://github.com/inexorabletash/polyfill/releases) for the tag name, e.g. \"v1.2.3\")\n\n### Files ###\n\nThe polyfills are roughly split up into files matching 1:1 with Web standards (specifications, living standards documents, etc). So there is [html.js](html.js) for [HTML](https://html.spec.whatwg.org), [dom.js](dom.js) for [DOM](https://dom.spec.whatwg.org), etc.\n\nSince I generally use several in my hobby projects, bundled/minified versions are available:\n\n* [web.js](web.js) (minified: [web.min.js](web.min.js)) includes the most common Web polyfills - it assumes ES2015 support\n  * Includes: [html.js](html.js) [dom.js](dom.js) [xhr.js](xhr.js) [cssom.js](cssom.js) [url.js](url.js) [fetch.js](fetch.js)\n* [polyfill.js](polyfill.js) (minified: [polyfill.min.js](polyfill.min.js)) has everything in [web.js](web.js) plus [es5.js](es5.js) and [es6.js](es6.js) and [es2016.js](es2016.js) and [es2017.js](es2017.js)\n\nMinification is done via https://github.com/mishoo/UglifyJS2\n\n\u003e Some of the files use `console.assert()` calls to catch bugs during development. These are\n\u003e automatically removed from the included minified versions. If you use your own minifying\n\u003e processor it may cause to assertions to appear when unnecessary function names are stripped.\n\u003e You can safely remove these lines as part of a build step (e.g. using `grep -V`), or use a\n\u003e minifier that does this automatically. For [UglifyJS2](https://github.com/mishoo/UglifyJS2)\n\u003e the option is: `drop_console`\n\n\nECMAScript / JavaScript Polyfills\n---------------------------------\n\n[ECMAScript 5](es5.md) - Previous standard, supported by browsers circa 2012..\n\n[ECMAScript 2015](es6.md) - Previous standard, supported by browsers circa 2016.\n\n[ECMAScript 2016](es2016.md) - Previous standard, supported by browsers circa 2017.\n\n[ECMAScript 2017](es2017.md) - Most recent standard. Implementation in progress or complete in latest browsers.\n\n[ECMAScript proposed](experimental/es-proposed.md) - Proposals for future editions of the standard. Here there be dragons.\n\n[JavaScript 1.X String Extras](js.js) - [ref](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String)\n  * String prototype: `trimLeft`, `trimRight`, `quote`\n\n\nHTML\n----\n[script](html.js) -\n[tests](https://inexorabletash.github.io/polyfill/tests/html.html) -\n[living standard](https://html.spec.whatwg.org)\n\n* `document.head` (for IE8-)\n* 'shiv' of newer HTML elements (`section`, `aside`, etc), to fix parsing (for IE8-)\n* `dataset` and `data-*` attributes [spec](https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) (for IE8+, not available in IE7-)\n  * `str = element.dataset[key]` - yields undefined if data-key attribute not present\n  * `element.dataset[key] = str` - fails unless data-key attribute already present\n* [Base64 utility methods](https://html.spec.whatwg.org/multipage/webappapis.html#atob) (for IE9-)\n  * `encodedString = window.btoa(binaryString)` - Base64 Encode\n  * `binaryString = window.atob(encodedString)` - Base64 Decode\n* [Animation Frames](https://html.spec.whatwg.org/multipage/webappapis.html#animation-frames) - [demo page](https://inexorabletash.github.io/polyfill/demos/raf.html)\n  * `id = window.requestAnimationFrame()`\n  * `window.cancelAnimationFrame(id)`\n\n\nDOM\n---\n[script](dom.js) -\n[tests](https://inexorabletash.github.io/polyfill/tests/dom.html) -\n[living standard](https://dom.spec.whatwg.org)\n\n* [Selectors](https://dom.spec.whatwg.org/#scope-match-a-selectors-string) (for IE7-) - adapted from [Paul Young](http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed)\n  * `element = document.querySelector(selector)`\n  * `elementArray = document.querySelectorAll(selector)`\n* `elem.matches(selector)` (for IE, Firefox 3.6, early Webkit and Opera 15.0)\n* `elementArray = document.getElementsByClassName(classNames)` (for IE8-)\n* `e = element.nextElementSibling`, `e = element.previousElementSibling` (for IE8)\n* Node constants: `Node.ELEMENT_NODE`, etc (for IE8-)\n* DOMException constants: `DOMException.INDEX_SIZE_ERR` (for IE8-)\n* [Events](https://dom.spec.whatwg.org/) (for IE8)\n  * Where `EventTarget` is `window`, `document`, or any element:\n    * `EventTarget.addEventListener(event, handler)` - for IE8+\n    * `EventTarget.removeEventListener(event, handler)` - for IE8+\n  * Event: `target`, `currentTarget`, `eventPhase`, `bubbles`, `cancelable`, `timeStamp`, `defaultPrevented`, `stopPropagation()`, `cancelBubble()`\n* Non-standard Event helpers for IE7- - adapted from\n* [Custom Events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent)\n* [QuirksMode](http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html)\n  * `window.addEvent(EventTarget, event, handler)`\n  * `window.removeEvent(EventTarget, event, handler)`\n* [DOMTokenList](https://dom.spec.whatwg.org/#interface-domtokenlist) - `classList`[spec](https://dom.spec.whatwg.org/#dom-element-classlist), `relList`[spec](https://html.spec.whatwg.org/multipage/semantics.html#the-link-element)\n  * DOMTokenList: `length`, `item(index)`, `contains(token)`, `add(token)`, `remove(token)`, `toggle(token)`\n  * `tokenList = elem.classList` - for IE8+\n  * `tokenList = elem.relList` - for IE8+\n  * Non-standard helpers for IE7-:\n    * `tokenList = window.getClassList(element)`\n    * `tokenList = window.getRelList(element)`\n* ParentNode: `node.prepend(nodes...)`, `node.append(nodes...)`\n* ChildNode: `node.before(nodes...)` , `node.after(nodes...)` , `node.replaceWith(nodes...)` , `node.remove()`\n\n\nFetch\n-----\n[script](fetch.js) -\n[tests](https://inexorabletash.github.io/polyfill/tests/fetch.html) -\n[living standard](https://fetch.spec.whatwg.org)\n\nExample:\n\n```js\nfetch('http://example.com/foo.json')\n  .then(function(response) { return response.json(); })\n  .then(function(data) { console.log(data); });\n```\n\nSupported:\n* Headers: `new Headers()`, `append(name, value)`, `delete(name)`, `get(name)`, `getAll(name)`, `has(name)`, `set(name, value)`, `[Symbol.iterator]()`\n* Body: `arrayBuffer()`, `blob()`, `formData()`, `json()`, `text()` - but conversions are limited\n* Request: `new Request(input, init)`, `method`, `headers`, `body`, `url`\n* Response: `new Response(body, init)`, `headers`, `url`, `status`, `statusText`, `body`\n* `fetch(input, init)`\n\n\nXMLHttpRequest\n--------------\n[script](xhr.js) -\n[tests](https://inexorabletash.github.io/polyfill/tests/xhr.html) -\n[living standard](https://xhr.spec.whatwg.org/)\n* [`XMLHttpRequest`](https://xhr.spec.whatwg.org/#interface-xmlhttprequest) (for IE6-)\n* [`FormData`](https://xhr.spec.whatwg.org/#interface-formdata) (for IE9-)\n\n\nCSS OM\n------\n[script](cssom.js) - [spec](https://dev.w3.org/csswg/cssom-view/)\n\nPolyfill for `width` and `height` in `getBoundingClientRect()` in IE8-\n\n\nURL API\n-------\n[script](url.js) -\n[tests](https://inexorabletash.github.io/polyfill/tests/url.html) -\n[living standard](https://url.spec.whatwg.org/)\n\n```javascript\nvar url = new URL(url, base);\nvar value = url.searchParams.get(name);\nvar valueArray = url.searchParams.getAll(name);\nurl.searchParams.append(name, valueOrValues);\nurl.searchParams.delete(name);\n\nvar p = new URLSearchParams('a=1\u0026b=2');\n```\n\n* URL: `href`, `origin`, `protocol`, `username`, `password`, `host`, `hostname`, `port`, `pathname`, `search`, `searchParams`, `hash`\n* URLSearchParams: `append(name, value)`, `delete(name)`, `get(name)`, `getAll(name)`, `has(name)`, `set(name, value)`, `entries()`, `keys()`, `values()`, `forEach(callback)` and `[Symbol.iterator]()` (if defined)\n\n\nUncommon Polyfills\n==================\n\nThe following are of limited use and are *not* included in the `web.js` / `polyfill.js` bundled versions.\n\nTiming\n------\n[script](timing.js)\n\n* [Efficient Script Yielding](http://w3c.github.io/setImmediate/)\n  * `id = setImmediate(callback, args...)`\n  * `clearImmediate(id)`\n\n\nKeyboard Events\n---------------\n[script](keyboard.js) -\n[demo page](https://inexorabletash.github.io/polyfill/demos/keyboard.html) -\n[draft spec](https://w3c.github.io/uievents/) ([also](https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm))\n\nKeyboardEvent: `code`, `key`, `location`, `KeyboardEvent.queryKeyCap(code)`\n\nIE7- only: Call `window.identifyKey(keyboardEvent);` in `keydown`/`keyup` handlers before accessing above properties.\n\n[more details](keyboard.md)\n\n\nGeolocation API\n---------------\n[script](geo.js) -\n[demo page](https://inexorabletash.github.io/polyfill/demos/geo.html) -\n[spec](http://www.w3.org/TR/geolocation-API/) -\nuses [freegeoip.net](https://freegeoip.net/)\n\n```javascript\nnavigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);\nvar watchId = navigator.geolocation.watchPosition(successCallback, errorCallback, options);\nnavigator.geolocation.clearWatch(watchId);\n```\n\nObsolete\n--------\n[Obsolete and Unmaintained Polyfills](obsolete/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finexorabletash%2Fpolyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finexorabletash%2Fpolyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finexorabletash%2Fpolyfill/lists"}