edotensei

1.0.4 • Public • Published

Edotensei.js

PRs Welcome Known Vulnerabilities NPM Version Build Status Contributors Bundlephobia Bundlephobia FOSSA Status

Simple Load HTML (Assets/Resources) on the fly (Browser).

madara

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 use-in-react
  • result in browser
    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

License

FOSSA Status

Readme

Keywords

none

Package Sidebar

Install

npm i edotensei

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

33.3 kB

Total Files

14

Last publish

Collaborators

  • ri7nz