Skip to content

Instantly share code, notes, and snippets.

@bantya
Created June 2, 2016 12:42
Show Gist options
  • Save bantya/a03304165433f1eb119d3a3ae12a8720 to your computer and use it in GitHub Desktop.
Save bantya/a03304165433f1eb119d3a3ae12a8720 to your computer and use it in GitHub Desktop.
js: attach dynamic css file using javascript.
var filename='http://path/to/your/cssfile.css?' + new Date().getTime();
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
document.getElementsByTagName("head")[0].appendChild(fileref);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment