Open LeaVerou opened 4 years ago
Any ideas to measure specificity? We could do it in BigQuery using a JS library, similar to how we parse the CSS with Rework. Does https://github.com/keeganstreet/specificity look like a viable tool for this?
Looks good! If it turns out to be too slow for our kind of usage, I have a simpler script somewhere that I've written though with a small sacrifice on correctness (that shouldn't really affect averages etc).
I actually wrote a selector parser for this which also has a specificity method: https://projects.verou.me/parsel It even has a perf optimization for non-list selectors like the ones Rework produces. Its specificity method returns an array of three numbers.
The JS I just pushed also calculates number of selectors & rules, as well as average selectors per rule (in addition to everything else), so I changed the title.
E.g. average specificity per selector
@estelle: