Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Reload CSS files without reloading the page
function reloadCSS() {
const links = document.getElementsByTagName('link');
.filter(link => link.rel.toLowerCase() === 'stylesheet' && link.href)
.forEach(link => {
const url = new URL(link.href, location.href);
link.href = url.href;

This comment has been minimized.

Copy link
Owner Author

kdzwinel commented Jul 28, 2017

reloadcss mov


This comment has been minimized.

Copy link

stowball commented Jul 29, 2017

You could use querySelectorAll('link[rel="stylesheet"]') to remove the need to filter()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.