Unverified Commit e603bc9d authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Disable router.prefetch in development (#53477)

## What?

Follow-up to #51830. That PR disables prefetching in `<Link>` but not in the router, so `router.prefetch` would still cause a prefetch and additional compile.
parent e757cac3
......@@ -267,8 +267,12 @@ function Router({
back: () => window.history.back(),
forward: () => window.history.forward(),
prefetch: (href, options) => {
// If prefetch has already been triggered, don't trigger it again.
if (isBot(window.navigator.userAgent)) {
// Don't prefetch for bots as they don't navigate.
// Don't prefetch during development (improves compilation performance)
if (
isBot(window.navigator.userAgent) ||
process.env.NODE_ENV === 'development'
) {
return
}
const url = new URL(addBasePath(href), location.href)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment