nextjs - ✅(Solved) Fix Legacy and unused JavaScript causing performance issues [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86562Fetched 2026-04-08 02:10:21
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
3
Author
Timeline (top)
subscribed ×3commented ×1cross-referenced ×1issue_type_added ×1

Fix Action

Fixed

PR fix notes

PR #87270: bugfix: remove polyfills w/ baseline 2020

Description (problem / solution / changelog)

Since Next.js upgraded the browserslist baseline to support:

  • Chrome 111+
  • Edge 111+
  • Firefox 111+
  • Safari 16.4+

I think we can remove some of the polyfills for features that became baseline somewhere between 2018 and 2020:

  • String.trimStart/trimEnd
  • Symbol.description
  • Array.flat/flatMap
  • Promise.finally
  • Object.fromEntries

I am leaving the others, because they became baseline in 2022-2023, which is still relatively recent.

Related items

Closes: https://github.com/vercel/next.js/issues/86785 https://github.com/vercel/next.js/discussions/85815 https://github.com/vercel/next.js/discussions/64330 https://github.com/vercel/next.js/issues/86562

Changed files

  • packages/next-polyfill-module/src/index.js (modified, +1/-117)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:47 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.3.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.13.1
Relevant Packages:
  next: 16.0.4 // Latest available version is detected (16.0.4).
  eslint-config-next: 15.5.4
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/next-learn/tree/main/seo

To Reproduce

  1. Ensure next 16.0.4 or the current version is installed.
  2. Run npm run build && npm run start.
  3. Open http://localhost:3000 in Chrome (incognito mode).
  4. Open DevTools and go the Lighthouse tab.
  5. Set the Mode to Navigation (Default) and Device to Mobile (if not already).
  6. Check only Performance under Categories.
  7. Click Analyze page load and wait for a report.
  8. In the report, find the following issues:
    • Legacy JavaScript
    • Reduce unused JavaScript
    • Avoid serving legacy JavaScript to modern browser.

Current vs. Expected behavior

I expected the above Lighthouse issues to not occur if I properly set the browserslist targets. They occur regardless of what I set.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:47 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.3.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.13.1
Relevant Packages:
  next: 16.0.4 // Latest available version is detected (16.0.4).
  eslint-config-next: 15.5.4
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Performance

Which stage(s) are affected? (Select all that apply)

next build (local), next start (local)

Additional context

No response

extent analysis

TL;DR

  • Review and adjust the browserslist configuration to ensure it accurately targets modern browsers and excludes legacy ones to potentially resolve the Lighthouse issues regarding legacy JavaScript.

Guidance

  • Verify that the browserslist configuration is correctly set up in the project's package.json or a separate .browserslistrc file to target modern browsers.
  • Check the Next.js documentation for any specific recommendations on configuring browserslist for optimal performance and compatibility.
  • Consider testing the application with different browserslist configurations to identify if the issue is indeed related to the browser targets.
  • Ensure that the next version (16.0.4) is compatible with the configured browserslist targets and the versions of other relevant packages like react and react-dom.

Example

No specific code example is provided due to the lack of direct code reference in the issue, but an example of a .browserslistrc file might look like:

>0.5%
last 2 versions
not dead

This example targets browsers with more than 0.5% market share, the last 2 versions of each browser, and excludes dead browsers.

Notes

The effectiveness of adjusting browserslist depends on the specific configurations and versions of dependencies used in the project. It's also important to consult the documentation of next, react, and other relevant packages for their recommendations on browser support and performance optimization.

Recommendation

  • Apply workaround: Adjust the browserslist configuration to better target modern browsers and exclude legacy ones, as this directly addresses the Lighthouse issues reported and is a common approach to resolving such performance and compatibility problems.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix Legacy and unused JavaScript causing performance issues [1 pull requests, 1 comments, 2 participants]