Zack Tanner and GitHub
0cf373a585
add flag to opt into smooth scroll detection & add warning ( #81563 )
...
**What:**
`layout-router` currently forces style recalculation on every navigation by manipulating the `scroll-behavior` CSS property on the `<html>` element. This would impact most navigations, even though most don't use smooth scrolling
**Why:**
To prevent smooth scrolling during router navigation (which can feel janky), Next.js temporarily resets `scroll-behavior` to `auto`, then restores the original value (#40642 ). While this solves the UX issue, it causes performance overhead for the vast majority of users who don't have smooth scrolling configured.
**How:**
This PR introduces an optimization that checks for a `data-scroll-behavior="smooth"` attribute before manipulating styles. Only users who explicitly opt into smooth scrolling will experience the style recalculation.
- The existing behavior is preserved by default
- Opt-in to the new behavior by setting `experimental.optimizeRouterScrolling: true` in Next.js config
- When smooth-scroll is detected on the document, a development warning is logged to notify that the default behavior will be changing in an upcoming major.
2025-07-12 10:38:37 -07:00
..
2023-10-13 15:40:14 -04:00
2023-07-05 19:22:34 -07:00
2023-07-05 19:22:34 -07:00
2024-11-19 09:44:42 +00:00
2025-06-16 13:42:20 +01:00
2023-07-05 19:22:34 -07:00
2023-07-05 19:22:34 -07:00
2025-05-15 14:26:19 +01:00
2025-04-24 07:28:50 -05:00
2025-06-10 08:00:17 -05:00
2025-04-24 07:28:50 -05:00
2025-05-12 08:32:57 -05:00
2025-05-07 10:09:12 +01:00
2025-04-25 08:08:57 +01:00
2025-04-25 08:08:57 +01:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-15 14:26:19 +01:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-25 08:08:57 +01:00
2023-07-05 06:11:16 -07:00
2025-05-15 14:26:19 +01:00
2025-05-12 08:32:57 -05:00
2025-06-16 13:42:20 +01:00
2023-07-05 06:11:16 -07:00
2025-04-25 08:08:57 +01:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-19 08:58:29 +00:00
2024-11-08 14:48:55 +00:00
2023-07-05 06:11:16 -07:00
2023-10-19 13:32:47 +00:00
2024-11-07 08:58:43 +00:00
2024-12-10 22:14:40 +01:00
2024-11-19 07:56:55 +00:00
2023-07-05 06:11:16 -07:00
2025-01-03 23:17:14 +00:00
2025-04-24 07:28:50 -05:00
2025-06-16 13:42:20 +01:00
2024-11-07 08:58:43 +00:00
2023-07-05 06:11:16 -07:00
2025-05-08 13:11:38 +01:00
2025-04-22 08:44:58 -05:00
2025-05-21 15:43:02 +01:00
2024-11-08 14:48:55 +00:00
2024-11-07 08:58:43 +00:00
2023-07-05 06:11:16 -07:00
2025-06-10 06:52:38 -05:00
2024-11-19 09:44:42 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-19 07:56:55 +00:00
2024-11-07 08:58:43 +00:00
2023-07-05 06:11:16 -07:00
2025-05-07 10:09:12 +01:00
2025-05-07 10:09:12 +01:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-19 09:44:42 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-19 09:44:42 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-24 07:28:50 -05:00
2023-07-05 06:11:16 -07:00
2024-11-19 09:44:42 +00:00
2025-04-24 13:40:54 -05:00
2025-04-25 08:16:35 -05:00
2025-05-08 13:11:38 +01:00
2023-09-13 11:06:29 -05:00
2023-07-05 06:11:16 -07:00
2025-04-24 13:40:54 -05:00
2025-04-24 13:40:54 -05:00
2024-11-08 14:48:55 +00:00
2024-11-04 23:16:21 +00:00
2023-09-13 11:06:29 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-21 15:43:02 +01:00
2025-05-08 13:11:38 +01:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-08 14:48:55 +00:00
2025-05-14 12:35:09 +00:00
2024-08-22 10:05:00 -05:00
2023-07-05 06:11:16 -07:00
2023-12-16 14:13:17 -06:00
2024-11-19 09:44:42 +00:00
2023-07-05 06:11:16 -07:00
2024-11-07 08:58:43 +00:00
2025-04-24 13:40:54 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-25 08:16:35 -05:00
2025-06-10 06:52:38 -05:00
2023-07-05 06:11:16 -07:00
2023-10-11 21:10:44 +00:00
2025-04-15 16:00:54 +01:00
2023-07-05 06:11:16 -07:00
2024-08-23 09:12:15 -05:00
2024-11-08 14:48:55 +00:00
2023-09-13 11:06:29 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-09-13 11:06:29 -05:00
2023-09-13 11:06:29 -05:00
2024-11-06 08:07:02 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-07-12 10:38:37 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-27 10:30:17 +01:00
2024-11-19 09:44:42 +00:00
2024-11-19 07:56:55 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-25 08:16:35 -05:00
2024-11-19 09:44:42 +00:00
2024-11-28 15:19:47 +01:00
2024-11-19 07:56:55 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-08 13:11:38 +01:00
2025-05-08 13:11:38 +01:00
2025-05-08 13:11:38 +01:00
2025-05-08 13:11:38 +01:00
2025-05-08 13:11:38 +01:00
2025-04-15 16:00:54 +01:00
2025-06-03 16:44:51 -07:00
2025-06-03 16:44:51 -07:00
2025-06-03 16:44:51 -07:00
2025-06-03 16:44:51 -07:00
2025-04-27 14:34:36 -07:00
2025-04-27 14:34:36 -07:00
2025-05-15 21:28:50 +02:00
2025-06-03 16:44:51 -07:00
2025-06-03 16:44:51 -07:00
2025-04-15 16:00:54 +01:00
2025-04-15 16:00:54 +01:00
2025-02-11 21:04:37 -06:00
2024-11-19 08:58:29 +00:00
2025-06-16 13:42:20 +01:00
2025-04-15 15:39:01 +00:00
2025-04-24 13:40:54 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-23 21:50:55 +09:00
2025-04-24 13:40:54 -05:00
2025-04-22 10:18:39 -05:00
2025-05-12 08:32:57 -05:00
2023-07-05 06:11:16 -07:00
2024-11-19 07:56:55 +00:00
2024-11-04 23:16:21 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-19 08:50:01 +00:00
2025-05-08 13:11:38 +01:00
2024-11-07 08:58:43 +00:00
2025-05-07 10:09:12 +01:00
2023-07-05 06:11:16 -07:00
2025-04-24 13:40:54 -05:00
2025-04-24 13:40:54 -05:00
2025-04-24 13:40:54 -05:00
2025-06-10 08:00:17 -05:00
2025-05-12 08:32:57 -05:00
2024-11-07 08:58:43 +00:00
2024-11-07 08:58:43 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-06-10 08:00:17 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-24 07:28:50 -05:00
2024-11-07 08:58:43 +00:00
2024-11-19 07:56:55 +00:00
2024-11-19 07:56:55 +00:00
2023-07-05 06:11:16 -07:00
2024-11-08 14:48:55 +00:00
2024-11-19 08:58:29 +00:00
2023-08-15 02:17:40 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-04-24 07:28:50 -05:00
2025-04-24 07:28:50 -05:00
2024-11-06 08:35:52 +00:00
2023-11-08 16:14:10 +00:00
2024-10-20 23:00:23 +00:00
2025-05-27 14:58:40 +00:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-15 14:26:19 +01:00
2025-04-25 08:16:35 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2024-11-05 07:28:23 +00:00
2025-06-10 08:00:17 -05:00
2023-07-05 06:11:16 -07:00
2023-07-05 06:11:16 -07:00
2025-05-08 13:11:38 +01:00
2025-05-08 13:11:38 +01:00
2025-04-22 08:44:58 -05:00
2025-04-25 08:08:57 +01:00
2023-07-05 06:11:16 -07:00
2025-04-24 07:28:50 -05:00
2024-11-08 11:20:34 -08:00
2025-05-15 14:26:19 +01:00
2024-11-06 08:16:40 +00:00
2023-07-05 06:11:16 -07:00
2024-11-08 14:48:55 +00:00
2025-04-15 16:00:54 +01:00
2025-04-15 15:39:01 +00:00
2025-05-12 08:32:57 -05:00
2024-11-07 08:58:43 +00:00