To capture a page after its web fonts and resulting layout are ready, navigate with chromedp, await the browser’s document.fonts.ready promise, then capture the page, viewport, or a selected element. The promise covers fonts used by the document and associated layout work; it does not guarantee that every declared font loaded or that application-specific content has finished loading.
Capture a screenshot after fonts are ready
Install chromedp in your Go module with go get github.com/chromedp/chromedp, and make sure a compatible Chrome or Chromium executable is available. This example writes a full-page PNG to page.png. The 45-second deadline is configurable, not a measured recommendation.
As an Amazon Associate I earn from qualifying purchases.
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 to capture. The context remains alive through navigation, the font-readiness wait, and capture; the deferred cancellations release it when the program exits. The code follows the documented chromedp API pattern and is not represented as a tested run.
What the font wait does—and does not—mean
document.fonts exposes the page’s FontFaceSet. Its ready promise resolves when fonts needed by the document have finished loading and layout operations are complete. That makes it a useful synchronization point before capturing typography-sensitive layouts. See MDN’s FontFaceSet.ready reference.
#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
- It is not a guarantee that every font declared in CSS loaded. A declared but unused face may not be needed, and
font-display: optionalfonts may remain unloaded if they could not load in time. - It is not an application-idle signal. If JavaScript fetches page data later, reveals content after an interaction, or changes fonts after initial rendering, wait for that page-specific state too.
For a known font and text combination that must be loaded, document.fonts.load() can request those fonts and returns a promise. Use it when you need to target a particular face rather than wait for the document’s currently used fonts.
Choose the capture area
| Desired output | chromedp action | Notes |
|---|---|---|
| Entire rendered page | chromedp.FullScreenshot(&buf, 100) |
In the documented implementation, quality 100 selects PNG; lower quality selects JPEG. |
| Current viewport | chromedp.CaptureScreenshot(&buf) |
Captures the visible browser viewport. |
| One DOM element | chromedp.Screenshot(selector, &buf, ...) |
Pass a CSS selector; a visibility query option can be used where appropriate. |
Each action places image bytes in the supplied byte slice. Save those bytes with os.WriteFile, as in the example. The official chromedp examples show element and whole-page capture patterns.
Wait for page-specific content when necessary
If the screenshot depends on content loaded after navigation, add a wait for the condition that actually means the needed content is ready. For example, use chromedp.WaitVisible for a selector that appears only once the target content is shown. A fixed sleep can still expire too early or waste time; an observable condition is usually a better fit for asynchronous page state.
Rank #2
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
Set a context deadline appropriate to your page and environment. A page that cannot finish navigation or font loading should return an error instead of keeping the process waiting indefinitely. Increase or otherwise adjust the deadline only when the page’s actual behavior warrants it.
Emulated viewport considerations
FullScreenshot overrides device emulation settings. If your workflow depends on emulated device or viewport metrics, account for that behavior: the chromedp example documentation points to device.Reset for resetting emulation and viewport settings. Do not assume a full-page capture preserves the same emulation configuration as a viewport capture.
Troubleshoot common failures
- The capture fails with a context deadline error: navigation or a readiness wait did not finish before the deadline. Check whether the target page is accessible from the machine running Chrome, whether it is still loading fonts or application data, and whether the deadline fits the page’s behavior.
- The screenshot uses fallback typography: confirm that the page actually uses the intended web font and that its font request can complete.
document.fonts.readydoes not guarantee every declared font loaded, including optional or unused faces. - Fonts look settled but content is missing: add a page-specific wait for the delayed content or state. Font readiness does not wait for arbitrary application work.
- The browser context is canceled unexpectedly: chromedp’s README notes that browser disconnection can cancel the context. Check whether Chrome exited or lost its connection, and ensure the browser process remains available for the capture.
- The full-page image has unexpected dimensions or emulation: review the effect of
FullScreenshoton device emulation settings and reset or reapply settings as needed.
For API details and examples, see the chromedp project documentation.
Rank #3
- 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.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot; its options include waiting for a selector, delay, or network idle, as well as full-page and element capture. Here is a cURL example (see the ScreenshotNeo documentation):
Free tools Windows power users keep installed
One-click scans. No signup required.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Frequently Asked Questions
Does document.fonts.ready wait for every font declared in the page’s CSS?
No. It resolves for fonts needed by the document and layout; unused faces and some optional fonts may remain unloaded.
Can I use chromedp to save a viewport screenshot instead of a full-page image?
Yes. Use chromedp.CaptureScreenshot(&buf) for the current viewport.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
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.




