LeaVerou / css-almanac

Repo for planning & voting on which stats to study
https://projects.verou.me/mavoice/?repo=leaverou/css-almanac&labels=proposed%20stat
34 stars 3 forks source link

Specificity & number of selectors #5

Open LeaVerou opened 4 years ago

LeaVerou commented 4 years ago

E.g. average specificity per selector

@estelle:

Specificity: what percent of selectors are 0-0-0 thru 5-5-5. What is the highest specificity found?

rviscomi commented 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?

LeaVerou commented 4 years ago

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).

LeaVerou commented 4 years ago

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.

LeaVerou commented 3 years ago

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.