javascript - Changing version numbers on window.reload() -
if had following <script>
tag in code:
<script src='http://your.site.com/js/big_script.js?version=1'></script>
how can version number automatically update each subsequent window.reload()
action placed on page?
page refreshes...
<script src='http://your.site.com/js/big_script.js?version=2'></script>
page refreshes...
<script src='http://your.site.com/js/big_script.js?version=3'></script>
and on... through use of javascript only?
i know localstorage
come in handy here implementing within <script>
tag itself? there way of doing this, or there alternative ways done?
in case i'm after javascript based solutions application pure html5/javascript/css3.
thanks in advance!
as noted, localstorage way go. downside of doing client side you'll have late bind script tag. try:
var my_site_cntr = parseint(localstorage.getitem('mysite.counter')||0); my_site_cntr++; localstorage.setitem('mysite.counter', my_site_cntr); var scrptelem = document.createelement("script"); scrptelem.type = "text/javascript"; scrptelem.src = "http://your.site.com/js/big_script.js?version=" + my_site_cntr; scrptelem.innerhtml = null; document.body.appendchild(scrptelem);
sources:
Comments
Post a Comment