duckweb_speculate

scalar · LOAD duckweb

duckweb_speculate(VARCHAR, VARCHAR, VARCHAR) -> VARCHAR

A speculation rules block, telling the browser which navigations to prepare for.

duckweb_head(200, 'text/html',
  duckweb_speculate('prerender', '/species/*', 'moderate'))

Emits a <script type="speculationrules"> block covering every link whose href matches pattern, so a click resolves against work the browser has already done.

This pairs with the client tiers: the worker answers a navigation locally, and a prerender means it has already answered it before the click.

The pattern is escaped twice over — as a JSON string, and against the HTML parser’s scan for </script, which does not care that it is inside one.