Skip to content

Implement Lightweight SVG Minification / Optimization Middleware #6222

@nishtha-agarwal-211

Description

@nishtha-agarwal-211

Problem Statement

The SVG badges produced by CommitPulse are visually stunning, with 3D isometric geometries, custom styling, glows, animations, and particle effects. However, these features make the SVG payload large (frequently over 80KB). For high-traffic profile READMEs, caching helps, but initial payload size optimization is crucial for page load times.
We need to implement a lightweight, edge-compatible SVG optimization step before returning the response in app/api/streak/route.ts.

Proposed Solution

  1. Add a custom post-processing utility (or integrate a lightweight, edge-compatible library) to optimize the SVG markup.
    • Note: Standard svgo is not edge-compatible out of the box due to Node.js built-in dependencies. The middleware must run on Vercel Edge Runtime.
    • The minifier should:
      • Remove redundant whitespace and line breaks outside text segments.
      • Remove unnecessary XML/HTML comments.
      • Shorten path commands and floats where possible.
  2. Add a minify=true query parameter (on by default) so users can toggle optimization if they encounter parsing issues.
  3. Keep layout structure and styling fully intact (do not break CSS animations, transitions, or particles).

Definition of Done (DoD)

  • Average SVG file size is reduced by at least 15–20%.
  • The Edge Runtime endpoint continues to run successfully (no imports of Node-only modules).
  • Generated SVGs remain perfectly valid XML and render exactly the same in major modern browsers.
  • Integration tests confirm minified vs. normal output parity.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions