Edotensei.js
Simple Load HTML (Assets/Resources) on the fly (Browser).
Instalation
$ yarn add edotensei --dev
$ npm install edotensei --save-dev
Usage
- NPM/Yarn
import Edotensei from 'edotensei'
const scriptList = [
// Load javascript
{
src: 'main.js', // URL
async: boolean,
defer: boolean,
rel: 'preload|prefetch|dns-prefetch'
},
// load css
{
src: 'main.css', // load css
rel: 'preload|prefetch|dns-prefetch'
}
// add more here {}
];
Edotensei.add(scriptList) // To Add Script Element in Body HTML
# Make sure to pass same array of scriptList instance/reference
Edotensei.remove(scriptList) // To Remove Script Element in Body HTML
- HTML
<script src="https://unpkg.com/edotensei@latest/dist/edotensei.min.js"></script>
<script>
const scriptList = [
{ src: "main.js", rel: "preload" },
{ src: "main.css", rel: "preload" },
{ src: "registerServiceWorker.js" },
{ src: "https://fonts.gstatic.com/", rel: "dns-prefetch" },
{ src: "https://fonts.googleapis.com/", rel: "dns-prefetch" }
];
Edotensei.add(scriptList);
</script>
Example in React
- add & remove on react lifecycle
- result in browser
Contribute & Help
- Star & Fork Edotensei
- Post any issues you find (please check existing issues before posting!)
- Post new feature requests
- Pull requests are welcome
Contributors
- Everyone who posted an issue / pull request