Code & Format

Speculation Rules Generator

Generate a valid Speculation Rules JSON for Prefetch and prerender; validate safe presets, URL patterns, and eagerness options in your browser.

Speculation Rules Configuration
Safe start: Conservative Prefetch Measure first with low-risk prefetch; enable prerender by narrowing its scope according to actual navigation data.
Runs entirely in the browser

Presets

Presets change the operation type and trigger sensitivity together.

Low resource usage

Rule Behavior

Choose what the browser should prepare, from which source, and how early.

Prerender can also execute the JavaScript code of the target page.
Patterns are automatically applied to matching links on the page.
Earlier triggering may use more bandwidth and CPU.

URL Scope

Enter a URLPattern pattern or a target URL on each line.

Example: /blog/* or /products/:slug
Always exclude session, payment, and state-changing paths.
Enter a valid CSS selector list. Matching links are not included in the rule.

Live Syntax and Risk Audit

The JSON structure, URLPattern inputs, and resource consumption choices are checked instantly.

Valid

Generated Code

1 rule · 1 target/pattern

Checking browser support…
Information

About Speculation Rules Generator

Speculation Rules API, prefetches (prefetch) or complete preparation in the background (prerender) instruction. When used correctly, it can significantly speed up subsequent page transitions; when used too broadly, it can unnecessarily consume bandwidth, server resources, and analytics measurements.

This tool; conservative, moderate and aggressive generates a rule from URLPattern patterns or an explicit URL list using presets. Add the output as plain JSON or as <script type="speculationrules"> You can receive it in the form of. The syntax, the CSS exclusion selector, and risky combinations are checked entirely in your browser.

Browsers that do not support Speculation Rules ignore this script type; normal links continue to work. Therefore, when configured correctly, the feature is an additional acceleration layer and does not replace the existing navigation flow.

How to use it?

Step by step

  1. Suitable for your traffic and resource usage Conservative, Moderate or Aggressive Select the preset.
  2. Lighter to process prefetch or the one that prepares the page completely prerender make the selection.
  3. Scope URL pattern or explicit URL list Define it with; exclude session, cart, and checkout paths.
  4. Resolve the syntax and resource consumption warnings in the live validation field.
  5. Copy the generated HTML tag or JSON output, or download it as a file.
FAQ

Frequently Asked Questions

prefetch allows the target document to be prefetched from the network; it does not run the page. prerender then loads and renders the target page as if it were in an invisible tab. Prerender can provide faster transitions, but it should be used more carefully because JavaScript, network requests, and analytics events may run before the click.

conservative expects strong user intent; moderate uses a signal such as a brief delay on the link. eager and especially immediate can run earlier and consume more resources. The browser may still choose not to apply a rule depending on the browser, device, and network conditions.

WordPress 6.8 can send a conservative prefetch rule by default to supporting browsers for suitable front-end links. First, in the page source, check whether an existing type="speculationrules" Check the script as well. Instead of adding a second conflicting rule, use wp_speculation_rules_configuration Customize the core configuration with the filter.

The script type is not recognized and the rule is ignored. The normal on the page <a href> links work unchanged; no special JavaScript polyfill is required. Therefore, do not connect link targets only to Speculation Rules, and preserve the normal navigation flow.

Exclude logout, login, cart, checkout, account, administration, one-time links, and all paths that change state upon a GET request. Because a prerendered page may run without a user click, it is suitable only for pages that are safe, idempotent, and do not leak personal data.