WebKit
Home of the WebKit project, the browser engine used by Safari, Mail, App Store and many other applications on macOS, iOS and Linux.
Top Related Projects
The official GitHub mirror of the Chromium source
SUPERSEDED by https://github.com/mozilla-firefox/firefox. Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org
Servo aims to empower developers with a lightweight, high-performance alternative for embedding web technologies in applications.
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Brave browser for Android, iOS, Linux, macOS, Windows.
Quick Overview
WebKit is an open-source web browser engine used by Safari, Mail, App Store, and many other apps on macOS, iOS, and Linux. It's designed to provide a platform for building fast, efficient, and standards-compliant web browsers and applications.
Pros
- High performance and efficiency, especially on Apple devices
- Strong focus on web standards compliance and security
- Extensive support for modern web technologies (HTML5, CSS3, JavaScript)
- Active development and regular updates from a large community
Cons
- Primarily optimized for Apple ecosystems, which may limit cross-platform consistency
- Can be complex to set up and build for developers new to the project
- Some features may lag behind other engines due to Apple's release cycle
- Limited customization options compared to some other open-source engines
Getting Started
To get started with WebKit development:
-
Clone the repository:
git clone https://github.com/WebKit/WebKit.git
-
Install dependencies (macOS example):
brew install cmake ninja
-
Build WebKit:
cd WebKit Tools/Scripts/build-webkit --release
-
Run MiniBrowser (a test browser):
Tools/Scripts/run-minibrowser --release
For more detailed instructions and platform-specific guides, refer to the official WebKit documentation.
Competitor Comparisons
The official GitHub mirror of the Chromium source
Pros of Chromium
- Larger community and more frequent updates
- Broader platform support, including mobile and desktop
- More extensive feature set and APIs for developers
Cons of Chromium
- Higher resource usage and memory footprint
- More complex codebase, potentially harder for new contributors
- Slower startup time compared to WebKit
Code Comparison
WebKit (JavaScript engine):
JSValue jsNumber(ExecState* exec, double d)
{
return JSValue(JSValue::EncodeAsDouble, d);
}
Chromium (V8 JavaScript engine):
Local<Number> v8::Number::New(Isolate* isolate, double value) {
return internal::Factory::NewNumber(value);
}
Both examples show number creation in their respective JavaScript engines. WebKit uses a simpler approach with JSValue
, while Chromium's V8 employs a more abstracted method using Isolate
and Factory
.
WebKit tends to have a more straightforward codebase, making it easier for developers to understand and contribute. Chromium, on the other hand, offers more flexibility and features at the cost of increased complexity.
SUPERSEDED by https://github.com/mozilla-firefox/firefox. Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org
Pros of gecko-dev
- More extensive documentation and contributor guidelines
- Broader platform support, including Firefox for Android and Firefox OS
- Larger community and more frequent contributions
Cons of gecko-dev
- Steeper learning curve due to more complex codebase
- Slower build times compared to WebKit
- Less integration with Apple's ecosystem
Code Comparison
WebKit (JavaScript engine):
JSValue jsNumber(ExecState* exec, double d)
{
return JSValue(JSValue::EncodeAsDouble, d);
}
gecko-dev (JavaScript engine):
JS::Value NumberValue(double d) {
int32_t i;
if (mozilla::NumberIsInt32(d, &i))
return JS::Int32Value(i);
return JS::DoubleValue(d);
}
Both examples show number handling in their respective JavaScript engines, but gecko-dev's implementation includes additional type checking for integer values.
Servo aims to empower developers with a lightweight, high-performance alternative for embedding web technologies in applications.
Pros of Servo
- Written in Rust, offering memory safety and concurrency benefits
- Modular architecture, allowing easier experimentation and component reuse
- Designed for parallel processing, potentially offering better performance on multi-core systems
Cons of Servo
- Less mature and stable compared to WebKit
- Smaller community and ecosystem support
- Limited compatibility with existing web technologies due to its experimental nature
Code Comparison
WebKit (C++):
RefPtr<Element> Element::createElement(const AtomString& localName, Document& document)
{
return createElement(QualifiedName(nullAtom(), localName, nullAtom()), document);
}
Servo (Rust):
impl Element {
pub fn create(
name: QualifiedName,
attrs: Vec<(QualifiedName, DOMString)>,
document: &Document,
) -> DomRoot<Element> {
// Implementation details
}
}
The code snippets show element creation in both projects. WebKit uses C++ with reference counting (RefPtr), while Servo leverages Rust's ownership model and type system. Servo's approach potentially offers better memory safety guarantees at compile-time.
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Pros of Electron
- Enables cross-platform desktop app development using web technologies
- Simpler learning curve for web developers transitioning to desktop apps
- Large ecosystem of tools and libraries specifically for Electron
Cons of Electron
- Larger application size due to bundled Chromium and Node.js
- Higher memory usage compared to native applications
- Potential security concerns due to full system access
Code Comparison
WebKit (Objective-C):
- (void)loadView {
[super loadView];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:webView];
}
Electron (JavaScript):
const { BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
Summary
WebKit is a rendering engine used by various browsers, while Electron is a framework for building desktop applications using web technologies. Electron offers easier cross-platform development but comes with larger file sizes and higher resource usage. WebKit provides a more native experience but requires platform-specific knowledge. The code examples demonstrate the different approaches: WebKit uses native code to create a web view, while Electron uses JavaScript to create a window and load HTML content.
Brave browser for Android, iOS, Linux, macOS, Windows.
Pros of Brave Browser
- Built-in ad and tracker blocking, enhancing privacy and performance
- Integrated cryptocurrency wallet and rewards system
- More user-friendly for non-technical users
Cons of Brave Browser
- Less flexible for developers compared to WebKit's engine-focused approach
- Smaller community and contributor base
- More opinionated design choices, potentially limiting customization
Code Comparison
WebKit (WebCore/page/scrolling/ScrollingCoordinator.cpp):
void ScrollingCoordinator::willCommitLayerTree()
{
if (m_scrollGestureInProgress)
updateScrollingTreeAfterScrollGesture();
}
Brave Browser (src/brave/browser/brave_content_browser_client.cc):
void BraveContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
int frame_tree_node_id,
ukm::SourceIdObj ukm_source_id,
NonNetworkURLLoaderFactoryMap* factories) {
ContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
frame_tree_node_id, ukm_source_id, factories);
}
The code snippets highlight the different focus areas of the projects. WebKit's code deals with low-level scrolling coordination, while Brave Browser's code is more concerned with higher-level browser functionality and customization.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
WebKit
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, Apple Books, and many other applications. For more information about WebKit, see the WebKit project website.
Trying the Latest
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Reporting Bugs
- Search WebKit Bugzilla to see if there is an existing report for the bug you've encountered.
- Create a Bugzilla account to report bugs (and comment on them) if you haven't done so already.
- File a bug in accordance with our guidelines.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
Getting the Code
Run the following command to clone WebKit's Git repository:
git clone https://github.com/WebKit/WebKit.git WebKit
You can enable git fsmonitor to make many git commands faster (such as git status
) with git config core.fsmonitor true
Building WebKit
Building for Apple platforms
Install Xcode and its command line tools if you haven't done so already:
- Install Xcode Get Xcode from https://developer.apple.com/downloads. To build WebKit for OS X, Xcode 5.1.1 or later is required. To build WebKit for iOS Simulator, Xcode 7 or later is required.
- Install the Xcode Command Line Tools In Terminal, run the command:
xcode-select --install
Run the following command to build a macOS debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead. If you
also need debug symbols (dSYMs), run:
Tools/Scripts/build-webkit --release DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
Embedded Builds
To build for an embedded platform like iOS, tvOS, or watchOS, pass a platform
argument to build-webkit
.
For example, to build a debug build with debugging symbols and assertions for embedded simulators:
Tools/Scripts/build-webkit --debug --<platform>-simulator
or embedded devices:
Tools/Scripts/build-webkit --debug --<platform>-device
where platform
is ios
, tvos
or watchos
.
Using Xcode
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
Select the "Everything up to WebKit + Tools" scheme to build the entire
project.
If you don't use a custom build location in Xcode preferences, you have to
update the workspace settings to use WebKitBuild
directory. In menu bar,
choose File > Workspace Settings, then click the Advanced button, select
"Custom", "Relative to Workspace", and enter WebKitBuild
for both Products
and Intermediates.
Building the GTK Port
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install
For development builds:
Tools/gtk/install-dependencies
Tools/Scripts/update-webkitgtk-libs
Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK, see the wiki page.
Building the WPE Port
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja
ninja
sudo ninja install
For development builds:
Tools/wpe/install-dependencies
Tools/Scripts/update-webkitwpe-libs
Tools/Scripts/build-webkit --wpe --debug
Building Windows Port
For building WebKit on Windows, see the WebKit on Windows page.
Running WebKit
With Safari and Other macOS Applications
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
iOS Simulator
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
To run other applications, for example MobileMiniBrowser, with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app --debug --iphone-simulator <application-path>
Using Xcode
Open WebKit.xcworkspace
, select intended scheme such as MobileMiniBrowser and an iOS simulator as target, click run.
Linux Ports
If you have a development build, you can use the run-minibrowser
script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Contribute
Congratulations! Youâre up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.
Top Related Projects
The official GitHub mirror of the Chromium source
SUPERSEDED by https://github.com/mozilla-firefox/firefox. Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org
Servo aims to empower developers with a lightweight, high-performance alternative for embedding web technologies in applications.
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Brave browser for Android, iOS, Linux, macOS, Windows.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot