Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Bundle Size Is a Habit, Not a ProjectFrontend

Nobody wanted to be the pull request that added 200KB. Printing the number changed behaviour faster than any policy did.

Muhammed Senussi

Bundle size behaves like a household budget. A big clear-out feels great and changes nothing about next month.

Put it in the pull request

A size budget enforced in CI, reported as a diff on every pull request, changes the conversation from "we should look at performance sometime" to "this change costs 34KB, is it worth it?" That is a question a reviewer can answer.

  • Report the gzipped delta, per entry point. Totals hide the regression that matters.
  • Fail the build on the budget, but make raising the budget a normal, reviewable action. A rule people cannot change becomes a rule people disable.
  • Watch dependencies with transitive weight: a date library, an icon set imported wholesale, a polyfill for a browser you dropped last year.

The most effective thing we ever did was print the delta as a comment. Nobody wanted to be the pull request that added 200KB, and no policy was needed.

2 Comments

  • Sanne de Vries

    August 6, 2024

    Nobody wanted to be the pull request that added 200KB. Social pressure beats policy every time.

    • Muhammed Senussi

      Muhammed Senussi

      AuthorAugust 6, 2024

      And it costs nothing to set up. The version that fails the build is useful, but the version that just prints the number changed behaviour faster in our team.

Leave a comment