-
-
Save miripiruni/92ec93d5641156328c48 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
// 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;})})() |
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; | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment