Technology News

The truth about CSS selector performance

Geez, leave it to Patrick Brosset to talk CSS performance in the most approachable and practical way possible. Not that CSS is always what’s gunking up the speed, or even the lowest hanging fruit when it comes to improving performance.

But if you’re looking for gains on the CSS side of things, Patrick has a nice way of sniffing out your most expensive selectors using Edge DevTools:

  • Crack open DevTools.
  • Head to the Performance Tab.
  • Make sure you have the “Enable advanced rendering instrumentation” option enabled. This tripped me up in the process.
  • Record a page load.
  • Open up the “Bottom-Up” tab in the report.
  • Check out your the size of your recalculated styles.

DevTools with Performance tab open and a summary of events.

From here, click on one of the Recalculated Style events in the Main waterfall view and you’ll get a new “Selector Stats” tab. Look at all that gooey goodness!

Now you see all of the selectors that were processed and they can be sorted by how long they took, how many times they matched, the number of matching attempts, and something called “fast reject count” which I learned is the number of elements that were easy and quick to eliminate from matching.

A lot of insights here if CSS is really the bottleneck that needs investigating. But read Patrick’s full post over on the Microsoft Edge Blog because he goes much deeper into the why’s and how’s, and walks through an entire case study.

Direct Link →

Quick Tip: How To Check if a Variable Is Set in PHP
Top 12 Node.js Books for Beginners and Advanced Coders

Related Articles

Mobile App Design Trends For 2021

mobile-app-design-trends-for-2021
2020 was full of surprises, however, some trends are clearly visible. Mobile development for different industries is still on the rise, and newly created startups face pandemic-provoked issues they need…

The DNS Zone For Beginners

Exploring the Potential of the Metaverse: A New World Awaits
For all intents and purposes, DNS can be considered almost like the internet’s phonebook. At least that’s how it’s most often metaphorically explained. However, your domain’s DNS zone is slightly…

How Effective Are Language Learning Apps?

How Effective Are Language Learning Apps?
The use of mobile Internet and the number of mobile device users are increasing day by day. Such changes are entirely determined. Now everyone strives for convenience and mobility in…