Lably
Skip to content

WebKit

Open source browser engine

  • 10 min read
  • 3 chapters

Related on Lably

Through Web browser, Google and JavaScript

WebKit started as a fork of the KHTML and KJS libraries from KDE, and has since been further developed by KDE contributors, Apple, Google, Nokia, Bitstream, BlackBerry, Sony, Igalia, and others. WebKit supports macOS, Windows, Linux, and various other Unix-like operating systems. On April 3, 2013, Google announced that it had forked WebCore, a component of WebKit, to be used in versions of Google Chrome under the name Blink. Since version 15 in May 2013, Opera web browser dropped its own Presto layout engine in favor of WebKit as implemented by Google in the Chromium project.

Its JavaScript engine, JavaScriptCore, also powers the Bun server-side JS runtime, as opposed to V8 used by Node.js, Deno, and Blink. WebKit's C++ application programming interface (API) provides a set of classes to display Web content in windows, and implements browser features such as following links when clicked by the user, managing a back-forward list, and managing a history of pages recently visited.

WebKit is open source and available under the BSD 2-Clause license with the exception of the WebCore and JavaScriptCore components, which are available under the GNU Lesser General Public License. As of March 7, 2013, WebKit is a trademark of Apple, registered with the United States Patent and Trademark Office.

Origins

The code that would become WebKit began in 1998 as the KDE HTML (KHTML) layout engine and KDE JavaScript (KJS) engine. The WebKit project was started within Apple by Lisa Melton on June 25, 2001, as a fork of KHTML and KJS. Melton explained in an e-mail to KDE developers that KHTML and KJS allowed easier development than other available technologies by virtue of being small (fewer than 140,000 lines of code), cleanly designed, and standards-compliant. KHTML and KJS were ported to macOS with the help of an adapter library and renamed to WebCore and JavaScriptCore. JavaScriptCore was announced in an e-mail to a KDE mailing list in June 2002, alongside the first release of Apple's changes.

According to Apple, some changes that called for different development tactics involved macOS-specific features which are absent in KDE's KHTML, such as Objective-C; KWQ (pronounced "quack"), an implementation of the subset of Qt required to make KHTML work on macOS, written in Objective C++; and macOS calls.

Split development

The exchange of code between WebCore and KHTML became increasingly difficult as the code bases diverged, because both projects used different coding approaches and had different approaches to code sharing. At one point KHTML developers said they were unlikely to accept Apple's changes and claimed the relationship between the two groups was a "bitter failure". They claimed Apple submitted their changes in large patches containing multiple changes with inadequate documentation, often in relation to future additions to the codebase. Thus, these patches were difficult for the KDE developers to integrate back into KHTML. Also, Apple had demanded that developers sign non-disclosure agreements before looking at Apple's source code, and even then, they were unable to access Apple's bug database.

During the publicized "divorce" period, KDE developer Kurt Pfeifle (pipitas) posted an article claiming KHTML developers had managed to backport many (but not all) Safari improvements from WebCore to KHTML, and they always appreciated the improvements coming from Apple and still do so. The article also noted that Apple had begun contacting KHTML developers to discuss improving the relationship and future cooperation. In fact, the KDE project was able to incorporate some of these changes to improve KHTML's rendering speed and add features, including compliance with the Acid2 rendering test.

Following the appearance of a story of the fork in the news, Apple released the source code of the WebKit fork in a public revision-control repository.

The WebKit team also reversed many Apple-specific changes in the original WebKit codebase and implemented platform-specific abstraction layers, making it significantly easier to commit the core rendering code to other platforms.

In July 2007, Ars Technica reported that the KDE team would move from KHTML to WebKit. Instead, after several years of integration, KDE Development Platform version 4.5.0 was released in August 2010 with support for both WebKit and KHTML, and development of KHTML continued until 2016 before it was officially discontinued in 2023.

Open-sourcing

On June 7, 2005, Safari developer Dave Hyatt announced on his weblog that Apple was open-sourcing WebKit (formerly, only WebCore and JavaScriptCore were open source) and opening up access to WebKit's revision control tree and the issue tracker.

In mid-December 2005, support for Scalable Vector Graphics (SVG) was merged into the standard build.

WebKit's JavaScriptCore and WebCore components are available under the GNU Lesser General Public License, while the rest of WebKit is available under the BSD 2-Clause license.

Further development

Beginning in early 2007, the development team began to implement Cascading Style Sheets (CSS) extensions, including animation, transitions and both 2D and 3D transforms; such extensions were released as working drafts to the World Wide Web Consortium (W3C) in 2009 for standardization.

In November 2007, the project announced that it had added support for media features of the HTML5 draft specification, allowing embedded video to be natively rendered and script-controlled in WebKit.

On June 2, 2008, the WebKit project announced that they had rewritten JavaScriptCore as "SquirrelFish", a bytecode interpreter. The project evolved into SquirrelFish Extreme (abbreviated SFX), announced on September 18, 2008, which compiles JavaScript into native machine code, eliminating the need for a bytecode interpreter and thus speeding up JavaScript execution. Initially, the only supported processor architecture for SFX was the x86, but at the end of January 2009, SFX was enabled for macOS on x86-64 as it passes all tests on that platform.

WebKit2

On April 8, 2010, a project named WebKit2 was announced to redesign WebKit. Its goal was to abstract the components that provide page layout and rendering cleanly from their surrounding interface or application shell, creating a situation where "web content (JavaScript, HTML, layout, etc) lives in a separate process from the application UI". This abstraction was intended to make reuse in WebKit2 simpler than in WebKit. WebKit2 had "an incompatible API change from the original WebKit", which motivated its name change.

The WebKit2 targets were set to Linux, macOS, Windows, GTK, and MeeGo-Harmattan. Safari for macOS switched to the new API with version 5.1. Safari for iOS switched to WebKit2 with iOS 8.

The original WebKit API has been renamed WebKitLegacy API. WebKit2 API has been renamed just plain WebKit API.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication