Implement performance monitoring and optimization infrastructure for Core Web Vitals #96
Reference in New Issue
Block a user
Delete Branch "copilot/optimize-web-performance-vitals"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Optimize web performance and Core Web Vitals for Internet-ID
Summary
This PR implements comprehensive web performance optimizations to achieve optimal Core Web Vitals scores. All acceptance criteria from the issue have been addressed.
✅ Acceptance Criteria Met
Performance Audits
Core Web Vitals Optimization
Performance Optimizations Implemented
Monitoring & Budgets
Documentation
📊 Key Metrics
Baseline Measurements
Performance Budgets
Target Core Web Vitals
🔧 Tools Integrated
npm run build:analyzenpm run perf:reportnpm run perf:audit🔒 Security
📝 Recent Changes (Latest Commit)
Addressed all PR review feedback:
📁 Files Changed
🚀 Next Steps
<img>tags with Next.js<Image>(5 instances)📖 Documentation
PERFORMANCE_SUMMARY.mdfor complete overviewweb/PERFORMANCE_OPTIMIZATIONS.mdfor technical detailsweb/performance-budget.jsonfor budget definitionsThis PR lays the foundation for excellent web performance. All infrastructure is in place to maintain and improve performance going forward.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Pull Request Overview
This PR implements comprehensive web performance optimizations for the Internet-ID application, establishing monitoring infrastructure, performance budgets, and CI/CD integration. The changes focus on achieving optimal Core Web Vitals scores through Next.js configuration enhancements, bundle analysis, and automated performance testing.
Reviewed Changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@@ -0,0 +1,102 @@name: Performance BudgetsThe workflow uses
--legacy-peer-depsflag which bypasses peer dependency conflicts. This could mask dependency issues. Consider investigating and resolving the peer dependency conflicts properly, or add a comment explaining why this flag is necessary.@@ -0,0 +1,28 @@import { NextRequest, NextResponse } from 'next/server';The edge runtime is configured, but there's no comment explaining why edge runtime was chosen over Node.js runtime. Adding a comment would help future maintainers understand the performance/architectural decision (e.g., lower latency, global distribution).
@@ -0,0 +1,42 @@'use client';navigator.sendBeacon()may returnfalseif the beacon cannot be queued, but the return value is not checked. This could result in lost metrics without any error handling. Consider checking the return value and falling back to fetch if it returns false.@@ -0,0 +1,135 @@/**The
supportsWebP()function creates a new Promise and Image every time it's called. Consider memoizing the result since WebP support doesn't change during a session. This would prevent redundant checks and improve performance.@@ -4,13 +4,45 @@ import path from "path";const __filename = fileURLToPath(import.meta.url);The
optimizePackageImportsconfiguration only includes 'qrcode' and 'react-dom', but 'react-dom' is already optimized by Next.js by default. Consider removing 'react-dom' from this list to avoid redundancy and only include packages that need explicit optimization.@@ -0,0 +1,148 @@#!/usr/bin/env nodeThe
formatBytesfunction has a potential issue whenbytesis negative.Math.log()of a negative number returnsNaN, which will cause incorrect output. Add validation to handle negative values or document that negative values are not supported.@copilot apply changes based on the comments in this thread
Applied all changes from the review feedback in commit
8348f15:formatBytes()sendBeacon()fallback by checking return valueoptimizePackageImportssupportsWebP()to prevent redundant checks--legacy-peer-depsflagAll changes have been tested and the build passes successfully.
@@ -0,0 +1,148 @@#!/usr/bin/env nodeFixed in commit
8348f15. Added validation to handle negative values - the function now returns 'Invalid size' when bytes is negative, preventing NaN fromMath.log().@@ -0,0 +1,42 @@'use client';Fixed in commit
8348f15. Now checking the return value ofsendBeacon()and falling back to fetch if it returns false.@@ -4,13 +4,45 @@ import path from "path";const __filename = fileURLToPath(import.meta.url);Fixed in commit
8348f15. Removed 'react-dom' from the optimizePackageImports list since Next.js already optimizes it by default.@@ -0,0 +1,28 @@import { NextRequest, NextResponse } from 'next/server';Fixed in commit
8348f15. Added a comment explaining that edge runtime was chosen for lower latency and global distribution of the analytics endpoint.@@ -0,0 +1,102 @@name: Performance BudgetsFixed in commit
8348f15. Added comments explaining that--legacy-peer-depsis needed due to peer dependency conflicts between next-auth and Next.js 15 canary, and will be resolved when next-auth is updated.@@ -0,0 +1,135 @@/**Fixed in commit
8348f15. The function now memoizes the result using a module-level variable, preventing redundant WebP support checks during a session.