Dynamic Include JavaScript, Style
export function includeJsOnce({ id, src }) {
if (document.querySelector(`#${id}`)) return false;
const script = document.createElement("script");
script.id = id;
script.type = "text/javascript";
script.src = src;
document.body.appendChild(script);
return true;
}
export function injectStyles(rule, id) {
$(`#${id}`).remove();
const div = $("<div />", {
html: `­<style>${rule}</style>`,
})
.attr("id", id)
.css("display", "none")
.appendTo("body");
}