UNPKG

polygonjs-engine

Version:

node-based webgl 3D engine https://polygonjs.com

23 lines (22 loc) 716 B
import {Poly as Poly2} from "../../engine/Poly"; export class CoreStylesheetLoader { static loadUrl(url) { const elements = url.split("."); const ext = elements[elements.length - 1]; if (ext != "css") { url = `${url}.css`; } if (!Poly2.inWorkerThread()) { const id = url.replace(/[\W_]+/g, "_"); let stylesheet = document.getElementById(id); if (!stylesheet) { stylesheet = document.createElement("link"); stylesheet.type = "text/css"; stylesheet.rel = "stylesheet"; stylesheet.href = `${url}?${performance.now()}`; stylesheet.id = id; document.getElementsByTagName("head")[0].appendChild(stylesheet); } } } }