Skip to content

Bundle Monitoring

21.4.1. Bundle Size Criteria

Build output sizes must not exceed the following thresholds.

ItemMaximum SizeMeasurement BasisTQS Requirement
Initial JavaScript300KBAfter gzip compressionMandatory
Single Chunk Maximum500KBAfter gzip compressionMandatory
Total CSS100KBAfter gzip compressionMandatory
Single Image Asset500KBOriginal sizeMandatory
  • Initial JavaScript is measured as the combined size of all JS files loaded at the entry point.
  • If a single chunk exceeds 500KB, code splitting must be applied to separate it.
  • Third-party libraries must be separated into a vendor chunk to improve caching efficiency.
  • CSS must be minimized by removing unused styles (PurgeCSS, etc.).

21.4.2. Analysis Tools

The following tools must be used to visually analyze bundle composition.

ToolPurposeApplication Timing
rollup-plugin-visualizerVite/Rollup bundle visualizationPost-build analysis
source-map-explorerSource map-based bundle analysisPost-build analysis
bundlephobiaPre-check package sizeBefore package adoption
  • Bundle analysis must be performed at minimum on a per-release basis (sprint end or version release).
  • Using rollup-plugin-visualizer to generate bundle composition reports (HTML files) is recommended.
typescript
// vite.config.ts
import { visualizer } from 'rollup-plugin-visualizer'

export default defineConfig({
  plugins: [
    visualizer({
      filename: 'dist/bundle-report.html',
      gzipSize: true,
    }),
  ],
})
  • Before adopting a new package, bundlephobia must be used to verify the package size and tree-shaking support.
  • Retaining analysis reports as build artifacts to track size change trends is recommended.

21.4.3. CI Size Verification

Build output sizes must be automatically verified in the CI pipeline.

  • After the build completes, output sizes must be measured and compared against the criteria defined in Section 21.4.1.
  • Builds exceeding the thresholds must be failed.
  • Integrating bundlesize or size-limit tools into CI for automated verification is recommended.
json
// package.json - size-limit configuration example
{
  "size-limit": [
    { "path": "dist/assets/*.js", "limit": "300 KB", "gzip": true },
    { "path": "dist/assets/*.css", "limit": "100 KB", "gzip": true }
  ]
}
  • Automatically commenting bundle size changes on PRs (Pull Requests) is recommended.
  • When size increases by 10% or more, the root cause must be analyzed during code review.

21.4.4. Performance Budget

A performance budget must be established and managed for each project.

Budget ItemThresholdMeasurement Method
Initial JS Size300KB (gzip)Build output measurement
Total CSS Size100KB (gzip)Build output measurement
LCP2.5 seconds or lessLighthouse CI
INP200ms or lessChrome UX Report
CLS0.1 or lessLighthouse CI
Lighthouse Performance Score90 or aboveLighthouse CI
  • The performance budget must be established at the beginning of the project and shared with the entire team.
  • When the budget is exceeded, the following procedure must be followed.
    1. Identify the code or resource causing the issue.
    2. Apply improvement measures such as code splitting, lazy loading, and resource optimization.
    3. Verify that the values have returned to within the defined thresholds after improvement.
  • Performance budget criteria must be reviewed on a 6-month cycle and adjusted to reflect changes in the technology landscape.
  • During review, the appropriateness of threshold values must be evaluated based on real user data (RUM).

TIENIPIA QUALIFIED STANDARD