Skip to content

Instantly share code, notes, and snippets.

@kawabataryo
Forked from psebborn/countCSSRules.js
Last active August 29, 2015 14:06
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 kawabataryo/e019bf2ff4bd79d3ba98 to your computer and use it in GitHub Desktop.
Save kawabataryo/e019bf2ff4bd79d3ba98 to your computer and use it in GitHub Desktop.
Bookmarklet
javascript:(function(){var c="",d="";if(!document.styleSheets){return;}for(var b=0;b<document.styleSheets.length;b++){a(document.styleSheets[b]);}function a(g){var h=0;if(g&&g.cssRules){for(var f=0,e=g.cssRules.length;f<e;f++){if(!g.cssRules[f].selectorText){continue;}h+=g.cssRules[f].selectorText.split(",").length;}d+="\nFile: "+(g.href?g.href:"inline <style> tag");d+="\nRules: "+g.cssRules.length;d+="\nSelectors: "+h;d+="\n--------------------------";if(h>=4096){c+="\n********************************\nWARNING:\n There are "+h+" CSS rules in the stylesheet "+g.href+" - IE will ignore the last "+(h-4096)+" rules!\n";}}}console.log(d);console.log(c);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment