Dynamic Import
A library that allows you to dynamically load (and unload) scripts, CSS, and HTML templates and files in a browser.
Useful for preloading (in background), loading and unloading scripts inside
the <head>
of an html page, or cases when you may want to keep your css, js and templates
in separate files and only want to import them into an HTML page at different times.
Installation
npm i dynamic-import
You can also use the dist files in the browser.
Usage
Load CSS files
;const cssPaths = 'path/to/css/file.css' 'path/to/another/css/file.css';style;
Load JavaScript files
Load script files dynamically. When called, the supplied script
will be loaded into the <head>
of the DOM and run immediately.
;script;
Load HTML files
Load HTML file contents into an already-existing DOM element.
;html;