Skip to content

Instantly share code, notes, and snippets.

@almeidap
Forked from eltoob/gist:4586719
Last active August 29, 2015 14:10
Show Gist options
  • Save almeidap/a6b545373d0a3e3603d9 to your computer and use it in GitHub Desktop.
Save almeidap/a6b545373d0a3e3603d9 to your computer and use it in GitHub Desktop.
$.each(document.styleSheets, function(index) {
var id = this.href || '[inline]',
rules = this.cssRules ? this.cssRules.length : 0,
selectors = 0;
$.each(this.cssRules, function() {
if (this.selectorText) {
try {
selectors += this.selectorText.split(',').length;
} catch (err) {
console.log(err);
}
}
});
var msg = 'Stylesheet ' + index + ': [id=' + id + ', rules=' + rules + ', selector=' + selectors + ']';
console.log(msg);
if(selectors >= 4095) {
alert(msg);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment