Skip to content

Instantly share code, notes, and snippets.

@marco-kretz
Last active July 6, 2017 13:11
Show Gist options
  • Save marco-kretz/75b49f274eb1d66c7a60e9ba6c3eadb8 to your computer and use it in GitHub Desktop.
Save marco-kretz/75b49f274eb1d66c7a60e9ba6c3eadb8 to your computer and use it in GitHub Desktop.
Import CSS file dynamically via JavaScript
function requireCSS(url) {
var cssLink = document.createElement("link");
cssLink.href = url;
cssLink.type = "text/css";
cssLink.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(cssLink);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment