Skip to content

Instantly share code, notes, and snippets.

@maciejmyslinski
Created May 18, 2020 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejmyslinski/2dcb06a8dcfe4859a9fd36d9c15966d1 to your computer and use it in GitHub Desktop.
Save maciejmyslinski/2dcb06a8dcfe4859a9fd36d9c15966d1 to your computer and use it in GitHub Desktop.
Array.from(document.styleSheets).reduce((acc, cssStyleSheet) => {
const classNamesCount = Array.from(cssStyleSheet.cssRules).reduce(
(count, cssRule) => {
if (cssRule.selectorText && cssRule.selectorText.startsWith('.')) {
return count + 1;
}
return count;
},
0
);
return acc + classNamesCount;
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment