Last active
December 15, 2016 15:50
-
-
Save elwinschmitz/b701a0a3f12b39995e86026f6f71f341 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(){ | |
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