Created
January 31, 2013 16:34
-
-
Save gdiggs/4684157 to your computer and use it in GitHub Desktop.
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
// based on http://stackoverflow.com/a/12313690/1198757 | |
var styleSheets = document.styleSheets, | |
totalStyleSheets = styleSheets.length, | |
maxIESelectors = 4095; | |
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("Stylesheet: "+styleSheet.href); | |
console.log("Total rules: "+totalRulesInStylesheet); | |
console.log("Total selectors: "+totalSelectorsInStylesheet); | |
if(totalSelectorsInStylesheet > maxIESelectors) { | |
console.log("Too many selectors for IE!"); | |
} | |
console.log("*********************") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment