Open-Source Engines Forked by Apple to Build Safari
This article provides a concise breakdown of the open-source components Apple forked to create the Safari web browser. It covers how Apple selected KHTML and KJS from the KDE project in the early 2000s and transformed them into WebCore and JavaScriptCore, the foundational pillars of the WebKit framework that powers Safari today.
In the early 2000s, Apple relied on Microsoft's Internet Explorer for Mac as its default web browser. Seeking independence and better performance for Mac OS X, Apple decided to develop its own browser, which would become Safari. Rather than writing the core technologies from scratch, Apple engineers evaluated existing open-source projects and chose to fork two specific components developed by the KDE project for the Konqueror web browser: KHTML and KJS.
For the rendering engine—the component responsible for parsing HTML and CSS to display web pages on the screen—Apple forked KHTML. Apple selected KHTML over other open-source alternatives, such as Mozilla's Gecko engine, because KHTML had a significantly smaller codebase, was cleanly written, and already possessed high compliance with web standards. Apple adapted KHTML to work within the macOS environment using an Objective-C wrapper and renamed their forked version WebCore.
For the scripting engine—the component responsible for executing JavaScript code on web pages—Apple forked KJS, which was KDE's JavaScript engine. Apple integrated KJS alongside their newly minted WebCore rendering engine and renamed the scripting component JavaScriptCore. While JavaScriptCore has undergone massive architectural rewrites over the decades to introduce just-in-time (JIT) compilation and extreme performance improvements, its origins remain directly rooted in KJS.
Apple combined WebCore and JavaScriptCore under a single umbrella framework known as WebKit. When Steve Jobs announced the Safari web browser in January 2003, Apple released the source code for their changes to KHTML and KJS back to the open-source community, fulfilling their obligations under the GNU Lesser General Public License (LGPL). In 2005, Apple made the entirety of WebKit open-source. The decision to fork KHTML and KJS ultimately shaped the modern web, as WebKit not only powers Safari on macOS and iOS today, but was also later forked by Google to create Blink, the engine that powers Google Chrome and Microsoft Edge.