Simple Load HTML (Assets/Resources) on the fly (Browser).
$ yarn add edotensei --dev
$ npm install edotensei --save-dev
- 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>
- Star & Fork Edotensei
- Post any issues you find (please check existing issues before posting!)
- Post new feature requests
- Pull requests are welcome
- Everyone who posted an issue / pull request