Skip to content

Add --wait-loaded flag for pages with async-rendered content #68

@avifenesh

Description

@avifenesh

Problem

Pages that render content asynchronously via JavaScript (e.g., GitHub traffic charts, SPAs with data fetching) return incomplete snapshots on initial goto. The first snapshot shows placeholder text like "Loading" or "Crunching the latest data" instead of the actual content.

Currently the workaround is to wait manually (e.g., sleep 5) and then run a separate snapshot command. This is wasteful and unreliable - the delay is a guess.

Proposal

Add a --wait-loaded flag (or similar) to goto that waits for async content to finish rendering before taking the snapshot. Detection heuristics:

  1. Network idle - wait until no pending XHR/fetch requests for N ms
  2. DOM stability - wait until no DOM mutations for N ms (similar to --wait-stable on click)
  3. Loading indicator absence - wait until common loading patterns disappear (spinners, "Loading..." text, skeleton screens)

Alternatively, make --wait-stable work on goto (currently it's only documented for click).

Example

# Current - requires 2 commands and a guess on timing
node web-ctl.js run session goto https://github.com/org/repo/graphs/traffic
sleep 5
node web-ctl.js run session snapshot

# Proposed - single command, waits for content
node web-ctl.js run session goto https://github.com/org/repo/graphs/traffic --wait-loaded

Impact

Reduces round-trips for async pages from 2-3 commands to 1. Eliminates unreliable sleep-based workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions