Skip to content

Instantly share code, notes, and snippets.

@elwinschmitz
Last active December 15, 2016 15:50
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 elwinschmitz/b701a0a3f12b39995e86026f6f71f341 to your computer and use it in GitHub Desktop.
Save elwinschmitz/b701a0a3f12b39995e86026f6f71f341 to your computer and use it in GitHub Desktop.
(function(){
function reloadCSS() {
var now = Date.now();
var stylesheets = document.querySelectorAll('link[rel=stylesheet][href]');
window.console.info('Reload! ' + now);
Array.prototype.forEach.call(stylesheets, function (element) {
var newUrl = element.href.replace(/(&|%5C?)forceReload=\d+/, '');
element.href = newUrl + (newUrl.match(/\?/) ? '&' : '?') + 'forceReload=' + now;
});
}
window.addEventListener('keyup', function (event) {
if (event.code === 'KeyR' && event.shiftKey === true) {
reloadCSS();
}
});
reloadCSS();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment