get a report of styles not used in this page
(function getStyles(){var CSSrules,allRules,CSSSheets, unNeeded, currentRule,isHover;
CSSSheets=document.styleSheets;
for(j=0;j<CSSSheets.length;j++){
for(i=0;i<CSSSheets[j].cssRules.length;i++){
currentRule = CSSSheets[j].cssRules[i].selectorText;
isHover = currentRule.indexOf(":hover")==-1?true:false;
if(!document.querySelectorAll(currentRule).length){
if(isHover){
unNeeded+=CSSSheets[j].cssRules[i].cssText+"<br>";
}
}
}
}
docBody=document.getElementsByTagName("body")[0];
allRulesContainer=document.createElement("div");
docBody.appendChild(allRulesContainer);
allRulesContainer.innerHTML=unNeeded;
return false
})()
Ever wanted to clean out your style-sheets from unneeded styles?
Open firebug and paste in this function in the console and click run.
You will see that in the bottom of the page there will be a list of all styles that where not applied.
Comments are only visible to Forrst members. Log in or Request an invite.
