Skip to content

Instantly share code, notes, and snippets.

@shinypb
Created January 8, 2013 17:32
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shinypb/4485878 to your computer and use it in GitHub Desktop.
Save shinypb/4485878 to your computer and use it in GitHub Desktop.
Bookmarklet to reload CSS without reloading the entire page
(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;})})()
@Jonic
Copy link

Jonic commented Jan 8, 2013

I've used this one for a while - it doesn't need any JavaScript libraries, so it might come in handy some time :)

http://david.dojotoolkit.org/recss.html

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