@shgysk8zer0/polyfills is a collection of JavaScript polyfills designed to provide
modern functionality in older browsers. This library provides a range of polyfills
for features including AbortSignal
, CookieStore
, Sanitizer
, and many more.
You can access @shgysk8zer0/polyfills in several ways:
You can use a CDN to access the library. Add the following script tag to your HTML file to load the latest version:
<script src="https://unpkg.com/@shgysk8zer0/polyfills[@version]/all.min.js"></script>
<script src="https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/all.min.js" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-xoY6kDRPTvbDfGdGA3S6Ercudev5mWGBWZIErLB38f7TeN6hV7zof6WBpzMdx/z0" fetchpriority="high" defer=""></script>
You can install the library as an NPM package and use it in your project. Use the following command to install the library:
npm install @shgysk8zer0/polyfills
[!Note] If using this polyfills package in a node environment, you want to use
node.js
instead ofall.js
. The node version omits polyfills that do not make sense in NodeJS, such as DOM. Simply usingimport '@shgysk8zer0/polyfills'
orrequire('@shgysk8zer0/polyfills')
should work.
You can add the library as a Git submodule to your project. Use the following command to add the library as a submodule:
git submodule add https://github.com/shgysk8zer0/polyfills.git [:path/to/destination]
To use the polyfills in your project, simply import them using ES6 modules:
import '@shgysk8zer0/polyfills';
// Or
import 'https://unpkg.com/@shgysk8zer0/polyfills/all.js';
This will load all the polyfills in the library.
If you only need certain polyfills, you can import them individually:
import '@shgysk8zer0/polyfills/sanitizer.js';
import '@shgysk8zer0/polyfills/trustedTypes.js';
import '@shgysk8zer0/polyfills/elementInternals.js';
You can avoid installing altogether while keeping the familiar syntax by using
an import map.
If you use Rollup, see @shgysk8zer0/rollup-import
.
for more details.
<script type="importmap">
{
"imports": {
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/all.min.js",
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/",
}
}
</script>
If you would like to contribute to the library, please follow these steps:
Please make sure that your changes are thoroughly tested and that they follow the same coding style as the rest of the library.
@shgysk8zer0/polyfills is licensed under the MIT license. See the LICENSE file for more details.