Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query metrics: Chapter 2. CSS #83

Closed
37 of 39 tasks
rviscomi opened this issue Jul 23, 2019 · 19 comments · Fixed by #128
Closed
37 of 39 tasks

Query metrics: Chapter 2. CSS #83

rviscomi opened this issue Jul 23, 2019 · 19 comments · Fixed by #128
Assignees
Labels
analysis Querying the dataset

Comments

@rviscomi
Copy link
Member

rviscomi commented Jul 23, 2019

Part Chapter Authors Reviewers Tracking Issue
I. Page Content 2. CSS @una @argyleink @meyerweb @huijing #4

READ ME!

All of the metrics in the table below have been marked as Able To Query during the metrics triage. The analyst assigned to each metric is expected to write the corresponding query and submit a PR to have it reviewed and added to the repo.

In order to stay on schedule and have the data ready for authors, please have all metrics reviewed and merged by August 5.

Assignments

ID Metric description Analyst Notes
02.01 Custom properties @rviscomi props prefixed by --, % of sites
02.02 @import @supports @rviscomi page -> css -> regex (note: the content of @supports is more complex with regex)
02.03 Filters @rviscomi page -> css -> regex
02.04 Blend modes @rviscomi page -> css -> regex
02.05 Logical properties @rviscomi page -> regex (note: attribute selectors also complex to group with regex)
02.06 Hsl vs hsla vs. rgb vs rgba vs. hex @rviscomi page -> regex
02.07 rem vs em vs px vs ex vs cm etc. @rviscomi page -> regex
02.08 classes vs ids @rviscomi  
02.10 Top CSS libraries @rviscomi page -> css or html -> regex (fingerprinting with regex (+ minifiers is extra complex) focus on top 5 libs?)
02.11 Top reset utilities @rviscomi possibly with fingerprinting with regex (+ minifiers is extra complex) focus on top 5 libs?
02.12 RTL vs. LTR @rviscomi page -> regex
02.13 Flexbox @rviscomi feature counter
02.14 Grid @rviscomi feature counter
02.15 Most Popular Snap Points @rviscomi page -> css -> regex (max-width + min-width)
02.16 max vs. min-width @rviscomi page -> css -> regex (counter)
02.17 Ems vs rems vs px in media queries @rviscomi page -> css -> regex (counter)
02.18 How many people using print style media queries @rviscomi page -> css -> regex (counter)
02.19 number of stylesheets per page @rviscomi  
02.20 Most popular names for stylesheets @rviscomi  
02.21 Minified vs unminified @rviscomi check for whitespace
02.22 # of fonts downloaded @rviscomi  
02.23 Types of fonts downloaded @rviscomi  
02.24 Average size of CSS load per site @rviscomi  
02.25 Average size of images loaded by stylesheets (inline and linked) @rviscomi need to look at initiator
02.32 Number of colors declared per site @rviscomi  
02.33 Number of duplicate colors per those sites @rviscomi whether colors are defined more than once
02.34 Number of fonts declared per site @rviscomi duplicate of metric above
02.35 Number of duplicate font family declarations @rviscomi  
02.36 Number different font size values per site @rviscomi  
02.37 Number of z-indices per site @rviscomi  
02.38 Most popular z index values (chart) @rviscomi  
02.39 Number of different media query values per site @rviscomi  
02.40 Number of different margins per site @rviscomi  
02.41 Number of transitions used per site @rviscomi  
02.42 Number of @keyframes declared per site @rviscomi  
02.43 Number of [id="foo"] @rviscomi  
02.44 Number of [class*='foo']``[class^='foo'] [class$='foo'][class~='foo'] @rviscomi  
02.45 Number of classes per element @rviscomi  
02.46 Average Length of classes @rviscomi  

Checklist of metrics to be merged

  • 02.01 Custom properties
  • 02.02 @import @supports
  • 02.03 Filters
  • 02.04 Blend modes
  • 02.05 Logical properties
  • 02.06 Hsl vs hsla vs. rgb vs rgba vs. hex
  • 02.07 rem vs em vs px vs ex vs cm etc.
  • 02.08 classes vs ids
  • 02.10 Top CSS libraries
  • 02.11 Top reset utilities
  • 02.12 RTL vs. LTR
  • 02.13 Flexbox
  • 02.14 Grid
  • 02.15 Most Popular Snap Points
  • 02.16 max vs. min-width
  • 02.17 Ems vs rems vs px in media queries
  • 02.18 How many people using print style media queries
  • 02.19 number of stylesheets per page
  • 02.20 Most popular names for stylesheets
  • 02.21 Minified vs unminified
  • 02.22 # of fonts downloaded
  • 02.23 Types of fonts downloaded
  • 02.24 Average size of CSS load per site
  • 02.25 Average size of images loaded by stylesheets (inline and linked)
  • 02.32 Number of colors declared per site
  • 02.33 Number of duplicate colors per those sites
  • 02.34 Number of fonts declared per site
  • 02.35 Number of duplicate font family declarations
  • 02.36 Number different font size values per site
  • 02.37 Number of z-indices per site
  • 02.38 Most popular z index values (chart)
  • 02.39 Number of different media query values per site
  • 02.40 Number of different margins per site
  • 02.41 Number of transitions used per site
  • 02.42 Number of @keyframes declared per site
  • 02.43 Number of [id="foo"]
  • 02.44 Number of [class*='foo']``[class^='foo'] [class$='foo'][class~='foo']
  • 02.45 Number of classes per element
  • 02.46 Average Length of classes
@rviscomi rviscomi added the analysis Querying the dataset label Jul 23, 2019
@rviscomi rviscomi added this to the Content written milestone Jul 23, 2019
@rviscomi rviscomi added this to TODO in Web Almanac 2019 via automation Jul 23, 2019
@rviscomi
Copy link
Member Author

rviscomi commented Aug 8, 2019

I've created a new table https://bigquery.cloud.google.com/table/httparchive:almanac.parsed_css containing a JSON object for each parsed CSS resource, for example:

{
  "type": "stylesheet",
  "stylesheet": {
    "rules": [
      {
        "type": "rule",
        "selectors": [
          ".tparrows:before"
        ],
        "declarations": [
          {
            "type": "declaration",
            "property": "line-height",
            "value": "normal",
            "position": {
              "start": {
                "line": 3,
                "column": 5
              },
              "end": {
                "line": 3,
                "column": 24
              }
            }
          }
        ],
        "position": {
          "start": {
            "line": 1,
            "column": 1
          },
          "end": {
            "line": 5,
            "column": 2
          }
        }
      }
    ],
    "parsingErrors": []
  }
}

Queries for this chapter that depend on specific style values should reference this table.

@rviscomi
Copy link
Member Author

rviscomi commented Aug 21, 2019

I've started analyzing these metrics. I'll be saving the results to this sheet. @una @argyleink I'd appreciate if you could follow along with the sheet to make sure that the results align with your intuition/expectations or if there's anything that needs to be scrutinized further. I can let you know when it's complete.

@rviscomi rviscomi mentioned this issue Aug 22, 2019
@rviscomi
Copy link
Member Author

rviscomi commented Aug 22, 2019

@una @argyleink

A couple of questions about the metrics:

  • 02.05 Logical properties
    • Can a logical property be defined as any property containing {block,inline}-{start,end} and/or exactly{block,inline}-size?
  • 02.42 Number of @keyframes declared per site
    • Given the CSS below, would you count this as one @keyframes declaration or two keyframes (from, to)?
@keyframes slidein {
  from {
    margin-left: 100%;
    width: 300%;
  }

  to {
    margin-left: 0%;
    width: 100%;
  }
}

@argyleink
Copy link
Contributor

that animation code hurts to look at, it's like every no no in 1 animation lol

i'd count that as 1. it's one @Keyframe animation with 2 steps

@rviscomi
Copy link
Member Author

Thanks! BTW I copied it from the MDN example :) https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes

@argyleink
Copy link
Contributor

just submitted a wiki patch to fix that code sample you referenced 👍

@rviscomi
Copy link
Member Author

Another question:

  • 02.10 Top CSS libraries
  • 02.11 Top reset utilities

For these metrics, do you have a list of libraries/utilities and/or know a way to detect them?

https://www.wappalyzer.com/categories/web-frameworks includes stuff like Bootstrap. Are there any other Wappalyzer detections we could leverage for these?

@nucliweb
Copy link

nucliweb commented Aug 22, 2019

CSS Frameworks

You have stateofcss

Reset Utilities

@nucliweb
Copy link

Here are a couple more resources:

@rviscomi
Copy link
Member Author

Thanks @nucliweb!

@nucliweb
Copy link

By the way, do you know about Project Wallace?
You may have some idea about a new metric (if possible)

Here are the Open Source Tools

@nucliweb
Copy link

What do you think of adding the APIs of Paint API and Typed OM of CSS Houdini as a metric?

They are two active APIs in Chrome
👉🏼 Is Houdini ready yet‽

It may be interesting to know if there are implementation and its trend

@una
Copy link

una commented Aug 23, 2019 via email

@nucliweb
Copy link

I have found an awesome project with CSS Houdini in production 👉🏼Extra.css 🤪

We can add CSS Houdini on Almanac 2020 😊

@nucliweb
Copy link

Btw, @una, the inspiration to add CSS Houdini as a metric I was have after reading Chrome Image Lazy Loading - Sites Already Using it on Week 1!

@rviscomi
Copy link
Member Author

Paint API is used in 7 (!!) stylesheets:

#standardSQL
SELECT
  client, page, url, REGEXP_EXTRACT(body, '(?i)((?:background|border)-image:\\s*paint\\([^;}]+)')
FROM
  `httparchive.almanac.summary_response_bodies`
WHERE
  (firstHtml OR type = 'css') AND
  REGEXP_CONTAINS(body, '(?i)(background|border)-image:\\s*paint\\(')
ORDER BY
  client, page, url
client page url style
desktop http://uupaa.hatenablog.com/ http://uupaa.hatenablog.com/ background-image: paint(“foo”)
desktop https://nteract.io/ https://nteract.io/ background-image:paint(ripple)
desktop https://whydocatsanddogs.com/ https://whydocatsanddogs.com/css/style.css background-image: paint(roughBox)
desktop https://www.outdoortoys.co.uk/ https://www.outdoortoys.co.uk/static/version1562932659/frontend/OutdoorToys/default/en_GB/css/styles.min.css background-image:paint(pattern)
mobile https://nteract.io/ https://nteract.io/ background-image:paint(ripple)
mobile https://whydocatsanddogs.com/ https://whydocatsanddogs.com/css/style.css background-image: paint(roughBox)
mobile https://www.outdoortoys.co.uk/ https://www.outdoortoys.co.uk/static/version1562932659/frontend/OutdoorToys/default/en_GB/css/styles.min.css background-image:paint(pattern)

Such small adoption itself might be noteworthy. Especially as a benchmark against future measurements.

Not sure how to detect Typed OM.

@nucliweb
Copy link

Typed OM

To detecting Typed OM, you can find in Javascript context:

  • The method attributeStyleMap
  • Any Numeric Factory (CSS.em, CSS.px, CSS.deg, CSS.number, etc...)

Sample

Sample from Working with the new CSS Typed Object Model

el.attributeStyleMap.set('padding', CSS.px(42));
const padding = el.attributeStyleMap.get('padding');
console.log(padding.value, padding.unit); // 42, 'px'

@rviscomi rviscomi moved this from TODO to In Progress in Web Almanac 2019 Aug 27, 2019
@rviscomi rviscomi mentioned this issue Aug 29, 2019
@rviscomi
Copy link
Member Author

Added metrics 02_10 and 02_11 to the results sheet. I was only able to match 3 reset utilities, but Wappalyzer already includes many of the libraries so we're fortunate to have good coverage there.

I wasn't able to write queries for these last two metrics:

02.21 Minified vs unminified
02.25 Average size of images loaded by stylesheets (inline and linked)

@una @argyleink PTAL at the results and LMK if anything jumps out. This should be ready to go for you to start writing.

Web Almanac 2019 automation moved this from In Progress to Done Aug 29, 2019
@argyleink
Copy link
Contributor

fascinating information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Querying the dataset
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants