-
-
Save llCorvinSll/04f887248e2c16dea859 to your computer and use it in GitHub Desktop.
Revisions
-
psebborn revised this gist
Jul 12, 2013 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,9 @@ function countCSSRules() { var count = 0; if (sheet && sheet.cssRules) { for (var j = 0, l = sheet.cssRules.length; j < l; j++) { if( !sheet.cssRules[j].selectorText ) { continue; } count += sheet.cssRules[j].selectorText.split(',').length; } -
psebborn revised this gist
Feb 23, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,16 +4,17 @@ function countCSSRules() { if (!document.styleSheets) { return; } for (var i = 0; i < document.styleSheets.length; i++) { countSheet(document.styleSheets[i]); } function countSheet(sheet) { var count = 0; if (sheet && sheet.cssRules) { for (var j = 0, l = sheet.cssRules.length; j < l; j++) { count += sheet.cssRules[j].selectorText.split(',').length; } log += '\nFile: ' + (sheet.href ? sheet.href : 'inline <style> tag'); log += '\nRules: ' + sheet.cssRules.length; log += '\nSelectors: ' + count; log += '\n--------------------------'; -
There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ function countCSSRules() { var results = '', log = ''; if (!document.styleSheets) { return; } for (var i = 0; i < document.styleSheets.length - 1; i++) { countSheet(document.styleSheets[i]); } function countSheet(sheet) { var count = 0; if (sheet && sheet.cssRules) { for (var j = 0, l = sheet.cssRules.length - 1; j < l; j++) { count += sheet.cssRules[j].selectorText.split(',').length; } log += '\nFile: ' + sheet.href; log += '\nRules: ' + sheet.cssRules.length; log += '\nSelectors: ' + count; log += '\n--------------------------'; if (count >= 4096) { results += '\n********************************\nWARNING:\n There are ' + count + ' CSS rules in the stylesheet ' + sheet.href + ' - IE will ignore the last ' + (count - 4096) + ' rules!\n'; } } } console.log(log); console.log(results); }; countCSSRules();