Created
January 8, 2013 17:32
-
-
Save shinypb/4485878 to your computer and use it in GitHub Desktop.
Bookmarklet to reload CSS without reloading the entire page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
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