Skip to content

Instantly share code, notes, and snippets.

@geckotang
Created July 10, 2013 02:28
Show Gist options
  • Save geckotang/5962985 to your computer and use it in GitHub Desktop.
Save geckotang/5962985 to your computer and use it in GitHub Desktop.
selector limit
var timer,
count_rule = 0,
count_maxrule = 4600,
sheet = document.styleSheets[0];
function addCSSRule(sheet, selector, rules, index) {
if(sheet.insertRule) {
sheet.insertRule(selector + "{" + rules + "}", index);
}
else {
sheet.addRule(selector, rules, index);
}
}
timer = setInterval(function(){
if (count_rule>=count_maxrule) {
clearInterval(timer);
}
console.log(count_rule);
addCSSRule(sheet, "div", "background:red;");
count_rule++;
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment