SnapDOMGitHub8K

SnapDOM / Labs / Capture Stages

Capture stages

A capture is a chain: a clone freezes the live DOM at one instant, and a render turns that clone into pixels. Not every consumer needs the whole chain, and the plugin is the one that knows. So it declares it:

// Clone only, no image
{ name: 'my-plugin', needs: 'clone' }

// Complete capture (the default)
{ name: 'my-plugin' }

v3 removed a third, shallower stage — needs: 'dom' — which ran the plugin against the live page and took no clone at all. Declaring that removed stage now throws.

The stage of a capture is the deepest stage its plugins declare, so one undeclared plugin keeps everything. A capture with no plugins behaves exactly as it always did.

What the numbers say

The clone stage skips render-stage asset embedding and serialization. The saving depends on the page and resources. Compare the timings above; neither stage promises a fixed fraction of a full capture.

Unavailable exports

Ask a shallow capture for pixels and it throws, naming the plugin that lowered the stage. Re-capturing on demand would hand back an image of a different instant, and the caller would have no way to tell.