Surfin' Safari

George and Lars on KHTML and WebKit

Posted by Maciej Stachowiak on Wednesday, December 13th, 2006 at 5:46 am

Longtime KDE/KHTML developers Lars Knoll and George Staikos recently gave a presentation on KHTML and WebKit at Yahoo. Here’s a video of their presentation. They cover the early history of KHTML, as well as some of the newer things going on with WebKit and KHTML.

One point they mention a number of times is that many sites do a user agent check specifically for Safari. Safari sends the following User-Agent header: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3.

We strongly recommend looking for the AppleWebKit string and its version number, *not* for Safari. There are many other browsers and other applications based on WebKit which should have a near-identical web compatibility profile, both o the Mac and the other platforms. These include other Mac browsers, like OmniWeb, Shiira and Sunrise Browser. They include ports like the S60 browser. And there are non-browser apps like NetNewsWire or Dashboard that may still include live web content.

For the vast majority of cases, you want to check for the layout engine, not for the specific app.

Rant aside though, there’s a lot of interesting info in the video and you should all watch.

10 Responses to “George and Lars on KHTML and WebKit”

  1. jamesandrews Says:

    On the point of agent checking: I’ve started using Shiira 2b2 and noticed yesterday that Google Calendars currently has this problem.

    I get an “unsupported browser” message, but it works fine with Safari iteself. I sent an e-mail to their support desk about it and linked back to this post.

    I’m sure they’ll fix it! :)

  2. Mr. Fussyfont Says:

    Why test for ‘AppleWebKit’ and not ‘KHTML’? I suppose Konquerer doesn’t have AWK in its agent string, so maybe that’s the reason — it would not be similar enough to Safari…?

  3. Pingback from On web usability and the fact that we’re not in Internet Explorer anymore, Toto at 1FPS : David Chartier:

    […] ; i George and Lars on KHTML and WebKit For the vast majority of cases, you want to check for the layout engine, not for […]

  4. Myrd Says:

    History keeps repeating itself. Ever wonder why every browser’s user agent header starts with “Mozilla/5.0″?

  5. Shawn Erickson Says:

    To bad folk don’t appear to read Apple’s Safari FAQ which recommends this…

  6. hyatt Says:

    The AppleWebKit string is where the version number of the framework is located.

  7. Neo Says:

    You should check for AppleWebKit specifically because this is what Apple calls its own HTML rendering engine, which at some point in the future may drop KHTML for a home-grown core, KHTML may be sold/closed down and/or renamed or become so divergent from Web Kit that the two are not interchangeable.

    The other reasons above also apply, specifically other non-Safari apps may use the Web Kit HTML rendering engine and checking for only AppleWebKit simplifies compatibility checking for *all* Web Kit-using apps.

    I recently did a small programming job for a third-party website to enable Web Kit compatibility and specifically went the AppleWebKit route for all the reasons stated above e.g. non-Safari browsers, future-proofing.

  8. mcroft Says:

    Personally, I think sites should check for needed features and never assume that the user agent indicates that the features of the browser are what the developer thought they were when the page was published. I still see sites with six year old browser detection that are can only determine the difference between MSIE and NS 4.x.

    Checking the agent string is not future proof. Checking for the feature you need is.

  9. asbjornu Says:

    User Agent string sniffing is pretty much braindead no matter what part of the string you might be looking for. Instead, you should as mcroft mentiones, check for features. What does the name of the browser matter? Isn’t what features it sports more interesting? Isn’t that really what you’re looking for with your UA string hack? I would recommend everyone doing UA sniffing to read the following:

  10. Pingback from Michael(tm) Smith » WebKit devs kicking some CSS ass:

    […] ’ Safari blog, make sure to also check out the video of KDE/KHTML developer-demigods Lars Knoll and George Staikos talking about KHTML and WebKit. If you’re a browser-technologies junkie (like me […]