Skip to content

Instantly share code, notes, and snippets.

@satishSKY
Created January 29, 2016 09:00
Show Gist options
  • Select an option

  • Save satishSKY/3aa35f95647e8105a131 to your computer and use it in GitHub Desktop.

Select an option

Save satishSKY/3aa35f95647e8105a131 to your computer and use it in GitHub Desktop.
Give dynamic versioning for css and js files by using javascript.
Versioning-of-js-and-css-
Give dynamic versioning for css and js files by using javascript.
var jsVersion = parseInt(Math.random()*1000000000); var script = document.getElementsByTagName('script'); var link = document.getElementsByTagName('link'); for (var int = 0; int < link.length; int++) { link[int].href = link[int].href + "?ver=" + jsVersion; console.log(link[int].href); }
for (var int = 0; int < script.length; int++) { script[int].src = script[int].src + "?ver=" + jsVersion; console.log(script[int].src); }
@satishSKY
Copy link
Author

done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment