@sealcode/add-to-head
v1.0.0
Published
Helpers for adding assets like css or js to head and await their readiness
Downloads
71
Readme
add-to-head
A simple library that lets you dynamicall add some CSS or JS to the HEAD of your HTML document. If the JS or CSS asset is already present in the document, it's not added a second time.
lang=js
import { addCSS, addJS } from "@sealcode/add-to-head";
addCSS("/my/style.css"); // adds a css file to the DOM
addCSS("/my/style.css"); // called second time, will not add another style link to the DOM
await addJS("/my/script.js") // add a JS script to the DOM and await until it is loaded