Skip to content

Instantly share code, notes, and snippets.

@Danilovonline
Created February 8, 2017 06:47
Show Gist options
  • Save Danilovonline/2cf65c62375155c711f0b381e6e077f7 to your computer and use it in GitHub Desktop.
Save Danilovonline/2cf65c62375155c711f0b381e6e077f7 to your computer and use it in GitHub Desktop.
Dynamic load CSS file
(function(){
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
var scheme = (document.location.href.indexOf('https://') === 0) ? 'https://' : 'http://';
fileref.setAttribute("href", scheme + 'example.com/example.css')
document.getElementsByTagName("head")[0].appendChild(fileref)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment