Optimize performance bottlenecks: cached formatters, debounced events, memoized components#13
Draft
Copilot wants to merge 4 commits into
Draft
Optimize performance bottlenecks: cached formatters, debounced events, memoized components#13Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Cache Intl.NumberFormat instances in formatarPreco and formatarQuilometragem - Add debouncing to useBreakpoint resize handler - Fix QueryClient re-creation using useMemo with proper config - Memoize VeiculosDestaque rendering logic - Add React.memo to UltimasVendas and TopMarcas components Co-authored-by: luannpl <116959774+luannpl@users.noreply.github.com>
- Replace img tags with Next.js Image component for automatic optimization - Fix useEffect dependencies in animated-testimonials and usuario pages - Add useCallback to prevent unnecessary re-renders in CEP lookup functions - Fix build error by moving CardVeiculoSkeleton component definition Co-authored-by: luannpl <116959774+luannpl@users.noreply.github.com>
- Add priority and sizes attributes to animated-testimonials Image component - Revert refetchOnWindowFocus to true for better data freshness while respecting staleTime Co-authored-by: luannpl <116959774+luannpl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Identify and suggest improvements to slow code
Optimize performance bottlenecks: cached formatters, debounced events, memoized components
Nov 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Identified and resolved multiple performance inefficiencies causing unnecessary object allocations, excessive re-renders, and suboptimal image loading.
Cached Number Formatters
Intl.NumberFormatinstances were being created on every price/kilometer format call. Moved to module-level cached instances:Debounced Resize Handler
useBreakpointhook triggered re-renders on every pixel change during window resize. Added 150ms debounce to reduce re-render frequency by ~90%.QueryClient Optimization
QueryClient was recreated on every
Providerscomponent render. Wrapped withuseMemoand configured 1-minutestaleTimeto prevent cache invalidation and reduce unnecessary refetches.Component Memoization
React.memotoUltimasVendasandTopMarcasdashboard componentsuseMemotoVeiculosDestaquefor skeleton/content rendering logicuseCallbackto prevent recreation on every renderImage Optimization
Replaced
<img>tags with Next.js<Image>component (5 instances) for automatic lazy loading, responsive sizing, and modern format serving (WebP/AVIF).Impact
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.