Skip to Content

Find your next home with Luxist's "Estate of the Day"
AOL Tech

Filed under: Design, Developer

Tests confirm CSS selectors slow load times

Most Web designers make liberal use of CSS selectors, but that spec's sibling, descendant and child selectors can cause what designer/developer Shaun Innman calls a "significant, negative impact on page rendering." This is confirmed in tests done by UI Specialist Jon Sykes that are published on his blog.

Fortunately for most designers, the performance impact is only in extreme situations. But it's definitely something to be aware of when writing CSS.

The test was based in part on a comment by Dave Hyatt on an entry from Inman's blog.

For the Web designer n00bs reading this: CSS selectors are names given to styles -- font-size, color, background-color, etc -- in internal and external style sheets that dictate a Web page's design. By using sibling, descendant (two or more selectors) and child selectors (a selector that's a "child" of another selector), designers can apply greater control over the CSS for their pages.

Sykes' test uses a 20,000-item loop in an HTML document. Within that document, he uses three levels of nested "div" tags, the lowest containing a "paragraph" tag that also contains an "anchor" tag. The anchor tag is targeted and styled using the CSS.

The test also consists of three parts: class (each anchor tag gets a unique class name), descendant selectors and child selectors. The results -- listed by the browsers with the largest performance hit -- were as follows:

See Sykes' graph of his results

Class

  1. Firefox 3 (OSX)
  2. Firefox 2 (OSX)
  3. IE 7
  4. IE6 and Safari (aprox. tie)

Descender selector

  1. Firefox 3 (OSX) and Firefox 2 (OSX) tie
  2. Safari
  3. IE 7
  4. IE 6

Child selector

  1. Safari and Firefox 3 (OSX) tie
  2. IE 6
  3. Firefox 2 (OSX)
  4. IE 7

Note that Opera 9 (OSX) was excluded because it couldn't render the test page for Sykes.

Sykes does point out that this test measures the performance under extreme circumstances -- there aren't many Web pages with this amount of markup or styling. But he does caution that descender and child selectors can cause at least a slight drop in browser performance.

You can download Sykes' tests in ZIP format.

[VIA Shaun Inman]

Reader Comments (Page 1 of 1)

Featured Time Waster

Civiballs is a beautiful, soothing physics puzzle Time Waster

CiviballsI have an absolute weakness for physics games, and while Civiballs isn't the strongest physics-based game, what it lacks in the physics department it makes up for a few times over in style and fun.

In Civiballs, you are presented with a few colored balls, and your goal is to get those balls into the same-colored urn on the level. The "civi" part of Civiballs is that there are 3 sets of levels to play, each representing a different civilization. While the civilization doesn't affect gameplay, the artwork for each level is beautifully themed to it's appropriate era.

To play the game, you are given only one tool - a sword with which to cut the chains that are holding the balls. The puzzle part of the game is in figuring out what order, and with what timing to cut each chain. Do it right, and all the right balls end up in the right urns, with no stray balls entering an urn (a no-no). Do it wrong, and you get to start over again.

Civiballs is not terribly deep on gameplay; the entire game can be completed in about 15 minutes. But if you enjoy this type of game, it will be a very enjoyable 15 minutes.

View more Time Wasters

Featured Galleries

Defective by Design, London: Protest Pictures
Microsoft Security Essentials
Chromium Pre-Alpha on CrunchBang Linux
Safari 4 Beta
10 Firefox themes that don't suck
IE8 RC1
Download Squad at the Crunchies After-Party
Download Squad at the Crunchies
WordPress 2.7
Cooking Mama: Mama Kills Animals
Windows 7 Hands On
Comodo Internet Security
Android First-look: Amazon.com MP3 Store
Android First-look: Twitroid
Google Reader Android
Android Hands-On
Twine 1.0
Photoshop Express Beta
Mozilla Birthday Cake
Palm stuff
Adobe Lightroom 1.1

 


Follow us on Twitter!

Flickr Pool

www.flickr.com

Download Squad bloggers (30 days)

#BloggerPostsCmts
1Lee Mathews7679
2Jay Hathaway681
3Brad Linder664
4Jason Clarke312
5Grant Robertson710
6Christina Warren28
7Nik Fletcher20

More Tech Coverage

AOL Radio

Joystiq

TUAW

BloggingStocks

Autoblog

Urlesque

Engadget

Wow.com

Switched.com

FanHouse