Skip to content

[Due for payment 2026-11-10] [Performance] Web: load decorative SVG backgrounds on demand instead of shipping them in main #104901

Closed

Description

@mountiny

Problem

On web, every SVG import compiles into a React component and ends up in the chunk that imports it. Nine large decorative backgrounds are imported statically, so all of them ship in main-*.bundle.js, which every page needs before NewDot can render:

  • the ice cream background of the early renewal offer page, light and dark
  • the 6 colour patterns of eReceipt tiles (EReceiptBGs.ts), shown behind card expenses without a receipt, per diem expenses, receipt files that are not images, and the MFA card authorization page
  • the background of the distance eReceipt (DistanceEReceiptPanel)

Together they are 593 kB of JS in main (141 kB brotli), which is 12.6% of main. None of them shows on the screen a user lands on, and many users never open these screens. Main gets a new content hash on almost every deploy, so returning users download these bytes again after each deploy.

Solution

On web, load each background with React.lazy(() => import(...)) inside <Suspense fallback={null}>, the same pattern SignInPageLayout/BackgroundImage uses for the sign-in background. Each SVG becomes its own async chunk, which is not requested during the initial load. The service worker precaches it after the page loads. If a chunk fails to load, the screen renders without the pattern and nothing else changes.

Native keeps the static imports in EReceiptBGs.native.ts, because Metro resolves an .svg import to an asset id and there is nothing to split.

Impact

Local staging builds of main and the PR branch, Chrome, cold load (empty HTTP cache, no service worker), 5 interleaved runs per build:

main PR change
main-*.bundle.js, brotli 1,124 kB 983 kB -141 kB (-12.6%)
main-*.bundle.js, raw 5,633 kB 5,039 kB -594 kB (-10.5%)
UI ready, signed in, Slow 4G + 4x CPU 62.02 s 61.30 s -0.72 s (5/5 pairs)
Sign-in form, Slow 4G + 4x CPU 45.38 s 44.91 s -0.47 s (5/5 pairs)

PR

#104857

Slack conversation

https://expensify.slack.com/archives/C05LX9D6E07/p1792783259774899

Issue OwnerCurrent Issue Owner: @Eskalifer1
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. self-assigned this
    on Oct 23, 2026
  2. melvin-bot commented on Oct 23, 2026

    @melvin-bot

    @mountiny — to hire @Eskalifer1 on Upwork, add the External label so a job is created and the offer is sent automatically.

  3. added and removed
    ReviewingHas a PR in review
    on Nov 3, 2026
  4. changed the title [-][Performance] Web: load decorative SVG backgrounds on demand instead of shipping them in main[/-] [+][Due for payment 2026-11-10] [Performance] Web: load decorative SVG backgrounds on demand instead of shipping them in main[/+] on Nov 3, 2026
  5. 13 remaining items

  6. melvin-bot commented on Nov 9, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  7. aimane-chnaif commented on Nov 10, 2026

    @aimane-chnaif
    Contributor

    Perf issue. No need checklist

  8. melvin-bot commented on Nov 12, 2026

    @melvin-bot

    @mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  9. mallenexpensify commented on Nov 13, 2026

    @mallenexpensify
    Contributor

    Claude posting on behalf of Matt:

    Ready. Job price: $175 (standard, created 2026-10-23, no Help Wanted).

    • Eskalifer1 (Contributor): 100%, via NewDot
    • aimane-chnaif (C+): 100%, via NewDot

    No deploy blockers or regressions on the issue or the PR.

    aimane-chnaif says a performance issue needs no checklist: comment

    Next: pay. No Caps+Y.

    Evidence
    • Resolving PR: #104857 by Eskalifer1, merged 2026-11-02, approved by aimane-chnaif, mountiny. No revert.
    • Assigned: Eskalifer1 2026-10-23, aimane-chnaif 2026-11-03.
    • Test videos: author 2/5, C+ 1/5.

    PAYPREP v1

  10. mallenexpensify commented on Nov 13, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @Eskalifer1 paid $175 via Upwork
    Contributor+: @aimane-chnaif due $175 via NewDot

  11. Eskalifer1 commented on Nov 13, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, this should be paid via Upwork.

    Btw, i have reached out to you in Slack couple of times about ND payments and didn't get any response 😭, so i send message to email for contributors, do you have access to it?

  12. mallenexpensify commented on Nov 15, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022122005598113467441

    I'll be in touch this coming week about NewDot payments, was a rough week last week.

  13. Eskalifer1 commented on Nov 15, 2026

    @Eskalifer1
    Contributor

    Hi! I have accepted, thank you!

    I will message you tomorrow via Slack, thank you!

  14. mallenexpensify commented on Nov 16, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2Task

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions