-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: include warning on polyfillio sheet; use cf
- Loading branch information
1 parent
fffa95b
commit b3534cf
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
--- | ||
title: Polyfill.io | ||
category: JavaScript libraries | ||
updated: 2018-08-20 | ||
updated: 2024-06-26 | ||
intro: | | ||
[Polyfill.io](https://polyfill.io) is a service that serves JavaScript polyfills. | ||
Polyfill.io is a service that serves JavaScript polyfills. | ||
--- | ||
|
||
> ⚠️ **CRITICAL SECURITY WARNING** | ||
> | ||
> The polyfill.io CDN domain is currently being used in a web supply chain attack and is serving malicious code. **Remove any references to this domain from your codebase immediately**. Use alternative CDN providers like cdnjs.cloudflare.com as shown in the examples below. | ||
## Usage | ||
|
||
### Default usage | ||
|
||
```html | ||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js"></script> | ||
``` | ||
|
||
{: .-wrap} | ||
|
||
This is the default script for Polyfill.io. | ||
|
||
### References | ||
|
||
* [API example](https://polyfill.io/v2/docs/api) _(polyfill.io)_ | ||
* [List of features](https://polyfill.io/v2/docs/features) _(polyfill.io)_ | ||
* [Cloudflare now serves polyfill.io](https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk) _(blog.cloudflare.com)_ | ||
|
||
## Optimized | ||
|
||
### For modern browsers | ||
|
||
```html | ||
<script>if(!(window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></scr'+'ipt>')}</script> | ||
<script>if(!(window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js"></scr'+'ipt>')}</script> | ||
``` | ||
|
||
This only includes polyfill.io when necessary, skipping it for modern browsers for faster load times. | ||
|
||
### Extra features | ||
|
||
```html | ||
<script>if(!(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,fetch"></scr'+'ipt>')}</script> | ||
<script>if(!(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=default,fetch"></scr'+'ipt>')}</script> | ||
``` | ||
|
||
This is the same as the previous, but also adds a polyfill for `window.fetch()`. We add a `window.fetch` check and loads the additional `fetch` feature. |