Skip to content

Instantly share code, notes, and snippets.

@rex
Created June 12, 2019 16:23
Show Gist options
  • Save rex/5bf62706f2725f66e9ebb942b1aa2577 to your computer and use it in GitHub Desktop.
Save rex/5bf62706f2725f66e9ebb942b1aa2577 to your computer and use it in GitHub Desktop.
A handy script to aid in UI development; reloads only CSS without reloading the entire page.
window.css_refresh_index = 0;
const begin = () => {
var nodes = document.querySelectorAll('link');
[].forEach.call(nodes, function (node) {
node.href += '?___ref=0';
});
}
const refresh = () => {
if (!window.css_refresh_index) {
window.css_refresh_index = 0;
}
window.css_refresh_index++;
let i = window.css_refresh_index;
var nodes = document.querySelectorAll('link');
[].forEach.call(nodes, function (node) {
node.href = node.href.replace(/\?\_\_\_ref=[0-9]+/, '?___ref=' + i);
});
console.log(`refreshed css ${i} time(s)`);
}
begin();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment