Skip to content

Instantly share code, notes, and snippets.

@matijs
Last active December 10, 2015 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matijs/4487795 to your computer and use it in GitHub Desktop.
Save matijs/4487795 to your computer and use it in GitHub Desktop.
Bookmarklet to reload CSS without reloading the page… in modern browsers.
javascript:void (function(){[].forEach.call(document.querySelectorAll("link[rel=stylesheet][href]"),function(b){var a=b.href.replace(/(&|\??)reload=\d+/,"");b.href=a+(a.indexOf("?")>=0?"&":"?")+"reload="+(new Date().valueOf())})})();
(function() {
// grab all stylesheets with a href
[].forEach.call(document.querySelectorAll('link[rel=stylesheet][href]'), function(item) {
// remove our cache buster if present
var href = item.href.replace(/(&|\??)reload=\d+/, '');
// add cache buster while preserving existing params
item.href = href + (href.indexOf('?') >= 0 ? '&' : '?') + 'reload=' + (new Date().valueOf());
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment