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 🙏

© 2026 – Pkg Stats / Ryan Hefner

script-type-module

v1.0.1

Published

<script type=module> polyfill

Readme

<script type=module> - the polyfill!

An attempt to build a polyfill for <script type="module">. Because the waiting is the hardest part.

This polyfill includes:

  • All import and export forms.
  • Import bindings compliant with the spec; meaning a dependency can update its exported value and your module binding will reflect that change.
  • A web worker architecture that allows for spawning multiple workers for faster load times (experimental).
  • Full source maps.

This is alpha-ish software that is tested, but not used for any real projects (yet). Check out the tests/ folder to see what's been worked on, submit any issues you encounter.

This polyfill uses a different type "module-polyfill" to avoid constraining browser implementations.

Install

npm install script-type-module

Use

<script src="./node_modules/script-type-module/polyfill.js"></script>

<script type="module-polyfill" src="./foo.js"></script>

Dynamic import

The stage 2 import() proposal allows you to dynamically import code based on runtime considerations. This is useful if you want to delay loading parts of the application for any reason (such as based on user input).

This polyfill includes support for import(). Here's an example usage:

/pages/home.js

export function page(){
  let section = document.createElement('section');
  section.innerHTML = `
    <h1>Home</h1>

    <p>Welcome home!</p>
  `;

  return section;
}

index.html

<main></main>

<script src="./node_modules/script-type-module/polyfill.js"></script>

<script type="module-polyfill">
  let page = location.hash.substr(1);

  import(`./pages/${page}.js`).then(ns => {
    document.querySelector('main').appendChild(ns.page());
  });
</script>

In this case we are dynamically inserting DOM based on the location.hash, so that if the URL is http://example.com#home the /pages/home.js module is dynamically imported and inserted into <main>.

FAQ

Why use this instead of a bundler?

Bundlers are not great for development workflows. Being able to create new .html pages to test out small parts of your application without creating a new build just for that, is a super powerful thing.

Should I use this in production?

No! This is primarily meant for better development workflows. Do a real build for production.

How does this compare to es-module-loader?

es-module-loader is a polyfill for the in progress whatwg/loader spec. This spec has been through several revisions going back many years and isn't likely to appear in browsers soon.

This polyfill is based on the already specified <script type="module"> that is coming to browsers soon (in Edge developer preview already). The hope is that most evergreen browsers will have support within 6 months and this will only be used for testing on older browsers.

Licence

BSD 2 Clause