Skip to content

Instantly share code, notes, and snippets.

@edjw
Created April 8, 2024 13:12
Show Gist options
  • Save edjw/398a394f1f4fdc11079e5b2a574250be to your computer and use it in GitHub Desktop.
Save edjw/398a394f1f4fdc11079e5b2a574250be to your computer and use it in GitHub Desktop.
CSS Naked Day JS
const styleElements = document.querySelectorAll(
'link[rel="stylesheet"], style'
);
const inlineStyleElements = document.querySelectorAll("[style]");
for (const styleElement of styleElements) {
if (styleElement.parentNode) {
styleElement.parentNode.removeChild(styleElement);
}
}
for (const inlineStyleElement of inlineStyleElements) {
inlineStyleElement.removeAttribute("style");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment