Rendering engine

On this page 7

A rendering engine (also called a browser engine or layout engine) is the core component of a web browser that converts HTML, CSS and media into the pixels shown on screen. It parses documents into the DOM and CSSOM, computes styles, calculates the geometry of every box, paints the result and hands layers to the compositor, while cooperating with a separate JavaScript engine that can change the page at any moment.

Among browser technologies, the rendering engine determines how standards are interpreted, how fast pages appear and which features are available. Today three engine families dominate: Blink in Chromium-based browsers, WebKit in Safari and all iOS browsers, and Gecko in Firefox.

How a rendering engine turns code into pixels

A rendering engine processes a page through a pipeline of stages, each producing a data structure consumed by the next. The sequence that the browser must complete before the first paint is known as the critical rendering path, and every stage can become a bottleneck.

The table outlines the main stages in the order a modern engine performs them.

StageInputOutput
HTML parsingByte stream of the documentDOM tree
CSS parsingStylesheets and inline stylesCSSOM
Style calculationDOM and CSSOMComputed style for every element
Layout (reflow)Styled render treePosition and size of every box
PaintLayout treeDisplay lists of drawing commands
RasterizationDisplay lists, often split into tilesBitmaps, usually produced on the GPU
CompositingRasterized layersFinal frame sent to the screen
Stages of the rendering pipeline

The HTML parser is incremental and error-tolerant: it follows the parsing algorithm in the HTML Living Standard, which defines exactly how malformed markup must be repaired, so all compliant engines build the same DOM from the same broken input. A preload scanner runs ahead of the parser to discover images, scripts and stylesheets early, which hides much of the network latency.

Major rendering engines and their lineage

The current engines share a common ancestry: WebKit began as a fork of KHTML from the KDE project, and Blink was forked from WebKit in 2013. Gecko descends from the Netscape codebase and remains the only major engine outside that lineage.

EngineMain browsersPaired JavaScript engineStatus
BlinkChrome, Edge, Opera, Brave, Samsung InternetV8Largest market share
WebKitSafari; all browsers on iOS and iPadOSJavaScriptCoreActive
GeckoFirefoxSpiderMonkeyActive
EdgeHTMLLegacy Microsoft EdgeChakraDiscontinued; Edge moved to Blink
TridentInternet ExplorerJScript and ChakraRetired
Rendering engines in current and recent use

Engine diversity matters because web standards are validated by independent implementations. When one engine dominates, its behavior and bugs tend to become de facto standards, and developers stop testing elsewhere. Cross-engine projects such as the Web Platform Tests suite and the yearly Interop effort exist to keep the engines consistent.

Rendering engine versus JavaScript engine

The rendering engine and the JavaScript engine are separate components with different responsibilities, although both usually run on the same main thread of a renderer process. The JavaScript engine executes scripts; the rendering engine owns the DOM and decides what the page looks like.

AspectRendering engineJavaScript engine
Primary jobParse, style, lay out and paint documentsParse, compile and execute JavaScript
Key data structuresDOM, CSSOM, layout tree, layer treeHeap, call stack, compiled code
ExamplesBlink, WebKit, GeckoV8, JavaScriptCore, SpiderMonkey
InteractionExposes the DOM through bindingsReads and mutates the DOM through those bindings
Division of responsibilities inside a browser

The boundary explains a classic performance trap. When a script writes a style and then immediately reads a geometric property such as offsetHeight, the rendering engine must perform a forced synchronous layout. Repeating this in a loop causes layout thrashing, which can turn a few milliseconds of work into hundreds.

Performance behavior that developers can influence

Different CSS changes trigger different amounts of pipeline work, and choosing cheap changes is the most effective rendering optimization. A browser targeting 60 frames per second has a budget of about 16.7 ms per frame, of which only part is available to page code.

ChangeStages triggeredRelative cost
width, top, font-sizeStyle, layout, paint, compositeHigh
color, background-color, box-shadowStyle, paint, compositeMedium
transform, opacityStyle and composite onlyLow, often handled off the main thread
DOM insertion of many nodesStyle and layout for affected subtreesDepends on scope
Cost of common visual changes

Modern engines limit work with containment and invalidation. The CSS contain property and content-visibility: auto tell the engine that a subtree is independent, so it can skip layout and paint for off-screen content. Animating only transform and opacity lets the compositor thread run animations smoothly even when the main thread is busy.

Compatibility issues and common misconceptions

  • A browser brand is not an engine. Chrome, Edge and Opera share Blink, so testing all three covers only one engine; on iOS, every browser uses WebKit regardless of its name.
  • Vendor prefixes such as -webkit- reveal engine history, not the browser in use; Blink and Gecko still honor many -webkit- properties for compatibility.
  • User-agent sniffing is unreliable; feature detection with @supports or script checks reflects what the engine actually implements.
  • Identical CSS can render differently in subpixel rounding, font rasterization and form controls, because these details are partly left to implementations.

The practical rule is to test on at least one browser per engine family and to treat engine-specific workarounds as temporary code with a documented reason.

The idea in brief

A rendering engine is the part of a browser that draws the web page. A website arrives as text instructions. The engine reads them and decides where every word, image and button goes. Then it paints the result on the screen.

It works like a print shop that receives a written layout plan and produces the finished poster. Different browsers use different print shops. That is why the same page can look slightly different in Safari and Firefox. A fast engine, and a page that is easy to draw, make the web feel quick.

A practical scenario

A news site receives complaints that its article pages stutter while scrolling on mid-range Android phones. A performance trace shows that a sticky header animates its top property on every scroll event, forcing the rendering engine to recalculate layout for the whole page in each frame and dropping the frame rate to about 25 frames per second.

The front-end team replaces the top animation with a transform: translateY() animation and applies content-visibility: auto to the long comment section below each article. The engine now handles the header movement on the compositor and skips layout for off-screen comments entirely.

Testing in Blink, WebKit and Gecko confirms consistent behavior, and scrolling returns to a steady 60 frames per second on the same devices without any change to the visual design.