Skip to main content

Excluding Links

Sometimes you may want to prevent Turbo from prefetching certain links. This article explains how to exclude specific links from prefetching.

Sometimes you may want to prevent Turbo from prefetching certain links. This article explains how to exclude specific links from prefetching.

Using the Data Attribute

Add data-turbo-prefetch="false" to any link you want to exclude:

<a href="/checkout" data-turbo-prefetch="false">Checkout</a>

This is useful for:

  • Links that trigger actions (logout, add to cart)

  • Links to pages with dynamic or personalized content

  • Links to external payment processors

Automatic Exclusions

Turbo automatically skips prefetching for these link types:

External links - Any link to a different domain is ignored. Only links within your store are prefetched.

Download links - Links with the download attribute are skipped since they trigger file downloads, not page navigation.

Anchor links - Links to sections on the same page (like #section-name) are ignored since no new page load is needed.

Non-HTTP URLs - Links using mailto:, tel:, javascript:, or other non-HTTP protocols are skipped.

When to Exclude Links

Consider excluding links that:

  • Perform actions on click (logout, form submissions)

  • Point to frequently-changing content

  • Are rarely clicked by visitors

  • Lead to very large pages that shouldn’t be preloaded

Example: Excluding Multiple Links

You can add the attribute to any link element:

<nav>
  <a href="/products">Products</a>
  <a href="/collections">Collections</a>
  <a href="/account/logout" data-turbo-prefetch="false">Logout</a>
</nav>

In this example, Products and Collections will be prefetched on hover, but Logout will not.

Did this answer your question?