Created
June 12, 2019 16:23
-
-
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.
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
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