close
Skip to content

[2.x] chore(js): remove Array.prototype.flat polyfill#4483

Merged
imorland merged 1 commit into2.xfrom
im/remove-array-flat-polyfill
Mar 21, 2026
Merged

[2.x] chore(js): remove Array.prototype.flat polyfill#4483
imorland merged 1 commit into2.xfrom
im/remove-array-flat-polyfill

Conversation

@imorland
Copy link
Copy Markdown
Member

Summary

Array.prototype.flat has been natively supported since Chrome 69, Firefox 62, Safari 12 (2018), and Edge 79. The polyfill was added for iOS < 12 support, which is no longer a target for Flarum 2.x.

Flagged by Google Lighthouse as 8.5 KiB of unnecessary legacy JavaScript in the forum.js bundle.

Changes

  • Delete src/common/utils/arrayFlatPolyfill.ts
  • Remove the side-effect import from src/common/index.ts

No call sites need updating — the three usages of .flat() in core (Application.tsx ×2, PaginatedListState.ts ×1) rely on the native implementation which is available on all supported browsers.

Test plan

  • yarn build in framework/core/js/ completes without errors
  • Run Lighthouse against a Flarum 2.x install and confirm the "Legacy JavaScript" warning for arrayFlatPolyfill is gone

@imorland imorland requested a review from a team as a code owner March 21, 2026 23:42
@imorland imorland changed the title chore(js): remove Array.prototype.flat polyfill [2.x] chore(js): remove Array.prototype.flat polyfill Mar 21, 2026
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 21, 2026
Array.prototype.flat has been supported natively since Chrome 69,
Firefox 62, Safari 12 (2018), and Edge 79. The polyfill was originally
added for iOS < 12 support, which is no longer a target for Flarum 2.x.

Removing it saves ~8.5 KiB from the bundled forum.js output.
@imorland imorland force-pushed the im/remove-array-flat-polyfill branch from cc88591 to 2741b93 Compare March 21, 2026 23:44
@imorland imorland merged commit 1738c62 into 2.x Mar 21, 2026
25 checks passed
@imorland imorland deleted the im/remove-array-flat-polyfill branch March 21, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant