Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a webpage after its web fonts and resulting layout are ready, navigate with chromedp, await document.fonts.ready in the page, then call the screenshot action for the viewport, full page, or a specific element. Save the returned image bytes to a file. Font readiness does not guarantee that every declared font loaded or that asynchronous application content is ready, so add a page-specific wait when the screenshot depends on either.

Capture a screenshot after web fonts are ready

The browser exposes document.fonts.ready, a promise that resolves when fonts needed by the document have finished loading and layout operations are complete. Await it after navigation and before capture. The following complete example uses chromedp’s documented actions; it is an implementation pattern, not a claim of a tested run. It requires a Go module with github.com/chromedp/chromedp and a compatible Chrome or Chromium executable available to chromedp.

package main

import (
    "context"
    "log"
    "os"
    "time"

    "github.com/chromedp/chromedp"
)

func main() {
    ctx, cancel := chromedp.NewContext(context.Background())
    defer cancel()

    ctx, cancelTimeout := context.WithTimeout(ctx, 45*time.Second)
    defer cancelTimeout()

    var image []byte
    err := chromedp.Run(ctx,
        chromedp.Navigate("https://example.com"),
        chromedp.Evaluate(`document.fonts.ready.then(() => true)`, nil),
        chromedp.FullScreenshot(&image, 100),
    )
    if err != nil {
        log.Fatal(err)
    }
    if err := os.WriteFile("page.png", image, 0o644); err != nil {
        log.Fatal(err)
    }
}

Replace https://example.com with the page you want to capture. The timeout shown is configurable, not a measured recommendation. The context remains active through navigation, the font wait, capture, and file write; deferred cancellation releases it when the program exits. For current API details, see the chromedp project.

Choose the capture area and output

Need chromedp action Output and behavior
Entire rendered page chromedp.FullScreenshot(&image, 100) In the documented implementation, quality 100 selects PNG; lower quality selects JPEG. It captures beyond the viewport.
Current viewport chromedp.CaptureScreenshot(&image) Captures the visible browser viewport.
One DOM element chromedp.Screenshot(selector, &image, ...) Captures the selected element; a visibility query option is available, as shown in the maintainer example.

All three actions return image bytes through the supplied byte slice. Write those bytes with os.WriteFile, as in the example. Check the chromedp documentation and maintainer examples for the API matching your pinned module version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Understand what font readiness guarantees

document.fonts.ready resolves after fonts used by the document have finished loading and layout operations are complete. It is not a promise that every font declared in CSS loaded. A declared font may be unused, and a font with font-display: optional may remain unloaded if it could not load in time. See MDN’s FontFaceSet.ready reference.

If you need a particular font and text combination, the browser’s document.fonts.load(...) API can force the specified fonts to load and returns a promise. This targeted wait differs from document.fonts.ready, which waits for fonts used by the document and layout resolution; consult MDN’s FontFaceSet.load reference.

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro

Wait separately for application content when necessary

Font readiness is not a general page-idle signal. If the site inserts data later, changes the page after an interaction, or loads the content your screenshot must show asynchronously, wait for that page-specific condition as well. A selector that appears only when the relevant content is ready is often more useful than an arbitrary sleep. chromedp documents wait actions such as WaitVisible; choose a selector or condition that reflects the page’s actual state.

  1. Navigate to the page.
  2. Wait for document.fonts.ready.
  3. If required, wait for the particular content or state your screenshot needs.
  4. Capture the page, viewport, or element.
  5. Write the returned bytes to disk and handle errors.

Account for emulation and browser lifetime

FullScreenshot overrides device emulation settings. If your workflow relies on emulated device or viewport metrics, account for that behavior; the documented example points to device.Reset for resetting emulation and viewport settings. Check the chromedp maintainer documentation for details.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Chrome runs headless by default in chromedp. The project README also notes that browser disconnection can cancel the context. If the run ends with context cancellation, check whether the Chrome process exited or lost its connection, as well as whether the deadline was reached.

Troubleshoot common failures

  • The screenshot uses a fallback font. The font may not be used by the document, may have failed to load, or may be optional and remain unloaded. Check the page’s font-loading behavior; if you know the exact font and text combination, consider document.fonts.load(...).
  • Fonts are ready but the page is incomplete. document.fonts.ready does not wait for application data or interaction-driven changes. Add a condition tied to the content that must appear.
  • The program times out. Navigation, font loading, or capture may exceed the configured context deadline. Choose a deadline suitable for your page and environment, and investigate slow or stalled resources rather than treating a longer fixed sleep as readiness.
  • The context is cancelled unexpectedly. Check whether Chrome or Chromium exited or disconnected; chromedp can cancel the context when the browser disconnects.
  • The full-page image has unexpected dimensions. FullScreenshot overrides device emulation settings. Review the emulation setup and reset or reapply settings as appropriate.
  • The output file is missing or empty. Confirm the run reached capture, inspect returned errors, and check that the process can write to the chosen path. The example calls log.Fatal for both chromedp and file-write errors.

Or skip the browser setup

If you would rather call a screenshot API than manage Chrome and chromedp, ScreenshotNeo takes screenshots through one GET request. For example, using cURL:

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Sign up for free.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does awaiting document.fonts.ready wait for every font declared on the page?

No. It waits for fonts used by the document and layout resolution; unused fonts and some optional fonts may remain unloaded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I use if I need only one known web font to load?

Use the browser’s document.fonts.load(…) for the specified font and text combination, then capture after its promise resolves.

Best Value
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

Does document.fonts.ready wait for images, API data, or interactions too?

No. Add a separate wait for the page-specific content or state your screenshot requires.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$247.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
$179.99
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$304.00

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.