Skip to content

Instantly share code, notes, and snippets.

@pietia
Last active December 19, 2015 05:59
Show Gist options
  • Save pietia/5907746 to your computer and use it in GitHub Desktop.
Save pietia/5907746 to your computer and use it in GitHub Desktop.
var
styleSheets = document.styleSheets,
totalStyleSheets = styleSheets.length;
for (var j = 0; j < totalStyleSheets; j++){
var
styleSheet = styleSheets[j],
rules = styleSheet.cssRules,
totalRulesInStylesheet = rules.length,
totalSelectorsInStylesheet = 0;
for (var i = 0; i < totalRulesInStylesheet; i++) {
if (rules[i].selectorText){
totalSelectorsInStylesheet += rules[i].selectorText.split(',').length;
console.log([rules[i].selectorText.split(',').length, rules[i].selectorText]);
}
}
console.log("Stylesheet: "+styleSheet.href);
console.log("Total rules: "+totalRulesInStylesheet);
console.log("Total selectors: "+totalSelectorsInStylesheet);
console.log("===========================");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment