How Embedding Base64 Images Affects Page Load Performance

This article examines the trade‑offs of converting image resources to Base64 and embedding them directly in HTML or CSS, measuring load and render times with the Navigation Timing API across desktop and mobile browsers, and presents real‑world test results.

Aotu Lab
Aotu Lab
Aotu Lab
How Embedding Base64 Images Affects Page Load Performance

Embedding image resources as Base64 strings lets developers place them directly in HTML or CSS, eliminating separate HTTP requests and potentially speeding up the first paint. However, the resulting HTML/CSS files become larger, which may impact parsing and rendering performance.

Measuring Performance with Navigation Timing

The article uses the Navigation Timing API to capture key timestamps during page load. The relevant properties are accessed as follows:

var timing = window.performance.timing;
// timing.domLoading – when the browser starts parsing the first byte of the HTML document
// timing.domInteractive – when the HTML and DOM are fully parsed
// timing.domContentLoadedEventStart – when DOM parsing finishes and resource loading begins
// timing.domContentLoadedEventEnd – when all resources (e.g., scripts) have finished loading
// timing.domComplete – when the entire page, including images, is fully loaded and ready

From these timestamps two derived metrics are calculated:

build = timing.domComplete - timing.domContentLoadedEventStart; // time between resource loading start and final render
complete = timing.domComplete - timing.domLoading; // total time from start of data receipt to full render

Test Scenario: Base64 Image in CSS

A 50 KB JPG image is encoded to Base64 and embedded in a CSS file, then applied as a background to 135 DOM elements, simulating a sprite‑like usage. The test environment includes:

Mac OS X El Capitan with Chrome 48

iPhone 6 Plus iOS 9

Meizu Note Android 4

Images illustrating the setup:

Navigation Timing values are taken from Chrome’s official documentation; results may differ on other platforms. In Android + WeChat the measured build time was consistently 0 ms, likely due to a different rendering mechanism.

Results

With caching disabled, the measurements were:

build: 150 ms

complete: 200 ms

These figures are influenced by network conditions and should be used for comparative purposes only.

Conclusion

Base64‑embedding can reduce request overhead and improve first‑paint speed, but the increased payload size may affect parsing and overall rendering time, especially on lower‑end devices or browsers with different rendering pipelines. Developers should benchmark on target platforms before adopting this technique.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Base64navigation timing
Aotu Lab
Written by

Aotu Lab

Aotu Lab, founded in October 2015, is a front-end engineering team serving multi-platform products. The articles in this public account are intended to share and discuss technology, reflecting only the personal views of Aotu Lab members and not the official stance of JD.com Technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.