Skip to content

Instantly share code, notes, and snippets.

@stephenway
Forked from shinypb/gist:4485878
Created January 8, 2013 22:35
Show Gist options
  • Save stephenway/4488652 to your computer and use it in GitHub Desktop.
Save stephenway/4488652 to your computer and use it in GitHub Desktop.
(function(){
$('link[rel="stylesheet"]').each(function(i, elem) {
// Make an anchor tag with the stylesheet's href -- this is a weird/handy way of
// working with URLs in the browser.
var anchorTag = $('a').attr('href', elem.getAttribute('href'))[0];
// Rewrite the URL to have a cache busting parameter. This assumes
// that any query params weren't significant.
anchorTag.search = "ts=" + (+new Date);
// Update the stylesheet link
elem.href = anchorTag.href;
})
})()
// Bookmarklet version (made using http://userjs.up.seesaa.net/js/bookmarklet.html)
javascript:(function(){$('link[rel="stylesheet"]').each(function(i,elem){var anchorTag=$('a').attr('href',elem.getAttribute('href'))[0];anchorTag.search="ts="+(+new Date);elem.href=anchorTag.href;})})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment