Webkit, jQuery & text-shadow rendering

 

Webkit, jQuery & text-shadow rendering

Posted by Dan Pacey on 18th March 2010
3 Comments

We’ve been working on a new site for an iPhone developer, and ran into some performance issues with Safari and Chrome. Looks like Webkit has trouble with text-shadow..

 

Safari and Chrome have a bit of trouble with text-shadow..

So there I was, merrily developing a new site for a client.

The three product panels were fine, but I wanted to add a little animation to reveal further information, so I turned to my favourite javascript library, jQuery.

Using jQuery to move things around, fade them in and out and generally spice things up is pretty common these days, so I was surprised when I ran into a few performance issues testing the site in Webkit-based browsers Safari and Chrome that I hadn’t heard about. Both were having a big problems with all the motion and fading, with some serious and unacceptable lag. Firefox and IE didn’t share these problems, so I wracked my brains trying to work out what might be the cause.

Usually Webkit-based browsers hold up as well, if not better than the other big-names. I checked if it was a problem with transparent .png elements or overlaid background graphics – nothing. I tried changing my jQuery code to use other methods instead of .fadeTo and .animate, but that didn’t fix it either.

Throughout the site I’m using the CSS3 text-shadow property to give the copy a nice finish against the background, making it stand off in a more interesting way.

text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.8);

This is something that IE doesn’t even support, and which is rendered differently depending on the browser platform – I realised that the way Webkit and Gecko (which Firefox is built on) render this is probably quite different, and tried removing the property from my panel <li>.

Voila.

This seems to be a pretty major issue for what is likely to be a much-used property over the coming years. Testing further, it seems that Safari (Windows) has particular trouble with this, even slowing on pages that contain no animation, effects or otherwise – it’s simply a bit slow at rendering text-shadow..

For now it seem I’ll have to set this property just for Firefox, which is not really ideal. But we live and learn, and that’s yet another thing to keep in mind when designing for the web.

UPDATE: I also note that Chrome makes a meal of kerning when text-shadow is applied. This can be resolved by using a 0px blur.

 

3 Comments on “Webkit, jQuery & text-shadow rendering”

Michael

18th November 2010 at 18:42

I figured this out, too, after spending trial-and-error time commenting out various CSS properties. I had been using text-shadow and -webkit-text-stroke to beautify the text in a site that has a lot of textual content. The use of those properties ended up giving me the white flash of death during page reload (and even repaint during a window resize!). Hopefully more and more browsers will delegate even this kind of stuff to the graphics card to speed up the repaint/reflow process. At least some kind of performance optimizations will have to be implemented as more sites start to use more CSS3 and HTML5 features.

Jonathon

29th June 2011 at 07:36

Interesting article – thanks for that.

We’re currently trying to track down some major performance problems in a webkit-only site.
Exactly how slow was the rendering of the text shadow? Half a second, 2 seconds?

Thanks

Dan Pacey

6th July 2011 at 23:04

It’s hard to give a figure to help you, but I’d say the difference was marked between text-shadow on and off. Something less than 25% of the framerate, possibly as much as 10%.

 
Copyright © 2010 Hench. All rights reserved.
Hench   About   Work   Wine Labels   Books   Blog   Terms of Service   Contact