npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wide/polyfiller

v2.1.1

Published

Polyfills loader on demand.

Downloads

476

Readme

Polyfiller

Load polyfills on demand.

Install

npm install @wide/polyfiller --save

Usage

This exemple will load assets/polyfills/object-assign.js on IE 11 only:

import polyfiller from '@wide/polyfiller'

polyfiller({
  path: 'assets/polyfills/',
  load: {
    'object-assign.js': {
      ie: '<=11'
    }
  }
})
  • path public folder of compiled polyfills
  • load collection of polyfills to load, accept a key/value combination
    • key: filename or url of the polyfill
    • value: criteria to satisfies (see bowser.satisfied)

Built-in polyfills

@wide/polyfiller comes with a set of well-known polyfills:

  • babel.js: core-js/stable and regenerator-runtime/runtime
  • closest.js: element-closest-polyfill
  • object-fit.js: object-fit-images and object-fit-videos
  • picture-fill.js: picturefill
  • object-assign.js: es6-object-assign
  • fetch: whatwg-fetch
  • svg.js: svg4everybody

These polyfills can be loaded in two steps, first import the needed ones using the presets collection:

import polyfiller from '@wide/polyfiller'
import presets from '@wide/polyfiller/lib/presets'

polyfiller({
  path: 'assets/polyfills/',
  load: {
    ...preset.babel,
    ...preset.fetch,
  }
})

Then, you need to compile them into the assets/polyfills:

// assets/polyfills/babel.js
import '@wide/polyfiller/lib/presets/babel'
// assets/polyfills/fetch.js
import '@wide/polyfiller/lib/presets/fetch'

Capabilities

To resolve which polyfill must be loaded, @wide/polyfiller makes use of the bowser lib and expose the main feature of the browser:

import capabilities from '@wide/polyfiller/lib/capabilities'

capabilities.touch    // true | false
capabilities.platform // desktop | mobile
capabilities.os       // linux | macos | windows
capabilities.engine   // trident | gecko
capabilities.name     // ie | chrome | firefox
capabilities.version  // number
capabilities.chrome   // true | false
capabilities.opera    // true | false
capabilities.firefox  // true | false
capabilities.safari   // true | false
capabilities.edge     // true | false
capabilities.ie       // true | false
capabilities.webp     // true | false

These capabilities can be exposed as window.capabilities and body css classes:

import { expose } from '@wide/polyfiller/lib/capabilities'

expose()

Libraries

This package uses :

Authors

License

This project is licensed under the MIT License - see the licence file for details