@shgysk8zer0/polyfills
v0.4.8
Published
A collection of JavaScript polyfills
Downloads
1,273
Readme
@shgysk8zer0/polyfills
@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.
Installation
You can access @shgysk8zer0/polyfills in several ways:
CDN
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>
With version and SRI
<script src="https://unpkg.com/@shgysk8zer0/[email protected]/all.min.js" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-xoY6kDRPTvbDfGdGA3S6Ercudev5mWGBWZIErLB38f7TeN6hV7zof6WBpzMdx/z0" fetchpriority="high" defer=""></script>
NPM
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.
Git Submodule
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]
Usage
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';
Import Map
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/[email protected]/all.min.js",
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/[email protected]/",
}
}
</script>
Contributing
If you would like to contribute to the library, please follow these steps:
- Fork the repository.
- Create a branch for your changes.
- Make your changes.
- Submit a pull request.
Please make sure that your changes are thoroughly tested and that they follow the same coding style as the rest of the library.
License
@shgysk8zer0/polyfills is licensed under the MIT license. See the LICENSE file for more details.