Last active
August 24, 2020 10:02
-
-
Save wortwart/0eb7fc68cf3a70a6c0467337e99b2adc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[document, ...Array.from(document.querySelectorAll('iframe'), frame => frame.contentDocument)] | |
.flatMap(doc => Array.from(doc.styleSheets)) | |
.flatMap(sheet => Array.from(sheet.cssRules)) | |
.flatMap(rule => { | |
if (!rule) return []; | |
if (rule.type === 1) return rule; | |
if (rule.type === 4 || rule.type === 12) return Array.from(rule.cssRules); | |
return []; | |
}).length; | |
// Counts CSS rules in document, excluding @import, nested frames, CSS in JS, and inline CSS | |
// not working in Firefox console due to restrictions with document.styleSheets | |
// shamelessly lifted from https://twitter.com/sir_pepe/status/1296821191219478534 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment