Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

WebReflection/import.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

import.js

donate

A dynamic import() polyfill.

Don't miss the related blog post.

Features

  • compatible with native ES2015 modules
  • compatible with native import ... from ...
  • compatible with common native export ... expressions
  • compatible with Babel transpiled ES2015 modules
  • compatible with relative paths
  • compatible with absolute paths

Usage

<!doctype html>
<!-- literally anything you need before -->
<script
    async
    src="import.js"
    data-main="js/main.js"
></script>
  • the src should point to import.js or its min.js version
  • the data-main should point to your module entry point
  • feel free to use or not deferred or async to delay execution
  • all modules will be loaded through XHR to avoid the need of a fetch polyfill
  • however, you can add any polyfill you need upfront

Use https://unpkg.com/import.js@latest as source if you'd like to use a CDN service.

Live test based on this folder.

You can test native ES2015 module export too. It requires a compatible browser (today any modern WebKit would do).

About

A dynamic import() polyfill

Resources

License

Stars

Watchers

Forks

Packages

No packages published