Technical SEO & Core Web Vitals

Free Speculation Rules Generator (2026)

Build a valid <script type="speculationrules"> tag for prerender or prefetch in seconds. Set eagerness, match URL patterns, and exclude cart, checkout, and logout links. No sign-up, no ads.

1. Action

2. Rule type

3. Match rules

Always exclude anything that changes state: cart, checkout, logout, admin.

4. Eagerness

Your speculation rules

<script type="speculationrules">
{
  "prerender": [
    {
      "where": {
        "and": [
          {
            "href_matches": "/*"
          },
          {
            "not": {
              "href_matches": "/cart*"
            }
          },
          {
            "not": {
              "href_matches": "/checkout*"
            }
          },
          {
            "not": {
              "href_matches": "/logout*"
            }
          },
          {
            "not": {
              "href_matches": "/wp-admin/*"
            }
          },
          {
            "not": {
              "selector_matches": "[rel~=\"nofollow\"]"
            }
          },
          {
            "not": {
              "selector_matches": "[target=\"_blank\"]"
            }
          }
        ]
      },
      "eagerness": "moderate",
      "referrer_policy": "same-origin"
    }
  ]
}
</script>

Paste the tag anywhere in the <head> or <body> of your pages.

How to use speculation rules

  1. Pick prerender for near-instant navigation, or prefetch for a cheaper head start.
  2. Start with document rules and moderate eagerness so speculation fires on hover.
  3. Exclude every state-changing URL: cart, checkout, logout, admin, and one-click actions.
  4. Paste the generated script tag into your site template.
  5. Verify in Chrome DevTools under Application → Speculative loads, and confirm the navigation shows as prerendered.
  6. Guard analytics with document.prerendering so prerendered pages are not counted twice.

Frequently asked questions

What is the Speculation Rules API?

It is a browser API that lets you tell Chrome and Edge which URLs to prefetch or prerender before the user clicks. You declare the rules as JSON inside a <script type="speculationrules"> tag, and the browser decides when to act on them.

What is the difference between prefetch and prerender?

Prefetch downloads only the document response, so navigation is faster but the page still renders on click. Prerender fully loads and renders the page in a hidden tab, making the navigation close to instant, at a higher CPU and bandwidth cost.

Which eagerness setting should I use?

Use moderate for broad document rules — it triggers on ~200ms hover or pointerdown. Use immediate only for one or two highly likely next URLs, and conservative when bandwidth or server load is a concern.

Do speculation rules work in every browser?

Prefetch and prerender speculation rules are supported in Chromium browsers such as Chrome and Edge. Safari and Firefox ignore the script tag, so it degrades safely with no errors for those users.

Can prerendering break analytics or ads?

It can double-count pageviews if your tags fire during prerender. Guard analytics with document.prerendering and the prerenderingchange event, and always exclude logout, cart, and other state-changing URLs from your rules.

Pair this with the page speed test and the CrUX monitor to measure the impact, or see all free SEO tools.