Created
March 14, 2016 21:41
-
-
Save donmccurdy/9a486d015f20b053c242 to your computer and use it in GitHub Desktop.
SO MANY FONT SIZES.
This file contains 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 characters
/** | |
* Count the number of distinct font sizes on the page. | |
* | |
* Tested in Chrome, no idea if this works elsewhere. | |
* | |
* @author Don McCurdy <dm@donmccurdy.com> | |
* | |
*/ | |
var sizes = {}; | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
for (var j = 0; document.styleSheets[i].cssRules && j < document.styleSheets[i].cssRules.length; j++) { | |
if (document.styleSheets[i].cssRules[j].style) { | |
sizes[document.styleSheets[i].cssRules[j].style.fontSize] = true; | |
} | |
} | |
} | |
delete sizes['']; | |
console.info('This page has %d distinct font sizes.', sizes.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment