Opens profile photo
Follow
Click to Follow csswizardry
Harry Roberts
@csswizardry
Consultant Web Performance Engineer: , , , , , , , and more • Writer • Speaker
Science & TechnologyLeeds, UK / ✈️csswizardry.comJoined March 2009

Harry Roberts’s Tweets

Oh my gosh, this was such a great talk from . So many takeaways! If you care about #webperf and #ux (and I hope you do!) then you should care about optimizing your hero images. Tracking and fixing your Largest Contentful Paint (LCP) time is a good place to start.
Quote Tweet
Being fast is more important than ever. But despite being the easiest metric to monitor, debug, and optimise, LCP is still the one that most websites struggle with. Get ready to ask for a pay rise, after @csswizardry's #perfnow talk: youtube.com/watch?v=JhTR2f
Embedded video
1:15
2.4K views
3
32
Silly little micro-optimisation, but this is a fully valid, functional HTML document—html/head/body tags are all optional, saving 39 bytes! <!DOCTYPE html> <title>Hello, world!</title> <h1>Hello, world!</h1> <script> document.body.classList.add('foobar') </script>
11
56
Show this thread
Pretty sweet gig, actually: a web-perf project whose key focus is their 2MB monolithic stylesheet. Two of my favourite things!
Quote Tweet
I first wrote about this SEVEN years ago, but I’m currently helping a client refactor a huge, huge CSS project: @⁠extend in Sass is almost always an anti-pattern. The simple way around is 5× smaller.
Show this thread
Image
2
23
Show this thread
I first wrote about this SEVEN years ago, but I’m currently helping a client refactor a huge, huge CSS project: @⁠extend in Sass is almost always an anti-pattern. The simple way around is 5× smaller.
Image
8
63
Show this thread
If we look at the kinds of selectors we’re dealing with, they’re all pretty gross: incredibly broad Key Selectors (e.g. * or :not([hidden])); substring selectors (e.g. [class*="icss-"]); counters (e.g. div:nth-child(3)); complex combinators (e.g. ~); and descendants.
2
12
Show this thread
This leads to a half-second Recalc Style! Roughly half of Recalc Style is spent on selector matching, so about 250ms is spent just working over selectors. We spent almost 1.4ms just matching ::before!
1
16
Show this thread
This page has 5,000 DOM nodes, but the Recalc Style event is only scoped to 1,984 of them. When a user opens the hamburger nav, a class is added to the BODY. This causes a style invalidation, and the whole CSS is reapplied against the page (well, in our case, 1,984 DOM nodes).
Screenshot of Edge DevTools showing CSS selector performance statistics resulting from simply opening a hamburger menu.
4
40
Show this thread
<🧵> CSS Selector Performance. It’s something that most people tell you not to worry about. But sufficiently bad selectors on a sufficiently large DOM can have a real impact on the user experience, and even on INP.
7
346
Show this thread
head, script[async][defer], script[async][defer]::before { display: block; } script[async][defer]::before { content: attr(src); background-color: white; color: red; padding: 10px; border: 10px solid; }
1
16
Show this thread
One of my favourite outcomes from workshops is when an attendee asks a question so good that I end up writing a whole article to answer it. Today: document.write() – why IS it so bad?
2
21
Show this thread
It’s the same for DOMContentLoaded (blog post incoming…). Internal browser events exist for a reason, and although they might not represent the user experience, neither does e.g. TTFB, yet we still happily track that. Internal events; internal significance.
1
4
Show this thread