An open API service indexing awesome lists of open source software.

https://github.com/WebReflection/import.js

A dynamic import() polyfill
https://github.com/WebReflection/import.js

Last synced: 9 months ago
JSON representation

A dynamic import() polyfill

Awesome Lists containing this project

README

          

# import.js

[![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/WebReflection/donate)

A dynamic [import()](https://tc39.github.io/proposal-dynamic-import/) polyfill.

Don't miss the [related blog post](https://twitter.com/WebReflection/status/856137076852621312).

### Features

- [x] compatible with **native ES2015** modules
- [x] compatible with native `import ... from ...`
- [x] compatible with common native `export ...` expressions
- [x] compatible with **Babel transpiled** ES2015 modules
- [x] compatible with **relative paths**
- [x] compatible with **absolute paths**

### Usage

```html

```

* 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](https://webreflection.github.io/import.js/) based on [this folder](https://github.com/WebReflection/import.js/tree/master/js).

You can test [native ES2015 module export](https://webreflection.github.io/import.js/?native) too. It requires a compatible browser (today any modern WebKit would do).