Skip to content

Improving performance #66

@fabiospampinato

Description

@fabiospampinato

I'm taking a closer look at my style recalculations, and it turns out the all CSS property is incredibly slow for no reason.

With no other CSS on the page, and a 4x CPU slowdown, I get ~14ms for a page of mine with ~200 elements on the page, which just this CSS:

*:where(:not(html, iframe, canvas, img, svg, video):not(svg *, symbol *)) {
  all: unset;
  display: revert;
}

If I exclude divs, like the following, my style recalculations drop to ~9ms:

*:where(:not(html, iframe, canvas, img, svg, video, div):not(svg *, symbol *)) {
  all: unset;
  display: revert;
}

If I also exclude spans, like the following, the time drops to ~4ms:

*:where(:not(html, iframe, canvas, img, svg, video, div, span):not(svg *, symbol *)) {
  all: unset;
  display: revert;
}

The crazy thing is that Chrome's user agent stylesheet, only sets display: block for div, and it doesn't even set anything for span.

So an insane amount of performance is being thrown out of the window for nothing really.

Possibly this should be taken into account, and some common elements, if not every element, should be special-cased and not be reset with all: unset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions