Add Vercel Speed Insights to your project#1
Open
vercel[bot] wants to merge 1 commit into
Open
Conversation
Implemented Vercel Speed Insights integration for the Rareness project. ## Summary Successfully integrated Vercel Speed Insights into the Rareness web application, a Vite-based vanilla JavaScript project that displays League of Legends skin collections. ## Changes Made ### Created/Modified Files: 1. **web/package.json** - Added @vercel/speed-insights dependency - Added `@vercel/speed-insights` (^1.3.1) to dependencies - No breaking changes to existing dependencies 2. **web/src/main.js** - Integrated Speed Insights initialization - Imported `injectSpeedInsights` function from '@vercel/speed-insights' - Called `injectSpeedInsights()` early in the application startup (before DOMContentLoaded) - This ensures performance tracking begins as early as possible in the page lifecycle ## Implementation Details The integration follows the documentation for "other" frameworks (vanilla JS/Vite). The approach used: - **Method**: Client-side injection using `injectSpeedInsights()` function - **Timing**: Injected at the top of main.js to capture performance metrics from the earliest point possible - **Placement**: Called before the DOMContentLoaded event listener, ensuring Speed Insights tracks the full page load performance ## Metrics Tracked Once deployed to Vercel, Speed Insights will automatically track: - **Largest Contentful Paint (LCP)** - When the largest content element is visible - **Cumulative Layout Shift (CLS)** - Visual stability during page load - **First Input Delay (FID)** - Responsiveness to user interactions - **Time to First Byte (TTFB)** - Server response time - **First Contentful Paint (FCP)** - When first content appears ## Build & Testing Results ✅ Build successful: `npm run build` produces optimized production bundle ✅ No linting errors introduced by changes ✅ No breaking changes to existing functionality ✅ Package.json properly updated with lock file ## Next Steps for Deployment 1. Enable Speed Insights in Vercel dashboard for this project 2. Deploy to Vercel (via `vercel deploy` or git push to connected repository) 3. After deployment, Speed Insights will automatically: - Inject tracking endpoint at `/_vercel/speed-insights/script.js` - Collect Web Vitals data from real user sessions - Display metrics in Vercel dashboard under the Speed Insights tab ## Technical Notes - The `injectSpeedInsights()` function is called only once in the app, as required - It runs on the client-side and is essential for capturing real user performance data - Works with both static and server-rendered content - Zero performance overhead when Speed Insights is not enabled on the Vercel project - Compatible with the existing performance monitoring code already in index.html (audit metrics for development purposes) ## Files Modified - web/package.json (added dependency) - web/package-lock.json (updated lock file) - web/src/main.js (added Speed Insights integration) All changes preserve the existing code structure and follow best practices for integrating Speed Insights with vanilla JavaScript applications on Vite. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Implemented Vercel Speed Insights integration for the Rareness project.
Summary
Successfully integrated Vercel Speed Insights into the Rareness web application, a Vite-based vanilla JavaScript project that displays League of Legends skin collections.
Changes Made
Created/Modified Files:
web/package.json - Added @vercel/speed-insights dependency
@vercel/speed-insights(^1.3.1) to dependenciesweb/src/main.js - Integrated Speed Insights initialization
injectSpeedInsightsfunction from '@vercel/speed-insights'injectSpeedInsights()early in the application startup (before DOMContentLoaded)Implementation Details
The integration follows the documentation for "other" frameworks (vanilla JS/Vite). The approach used:
injectSpeedInsights()functionMetrics Tracked
Once deployed to Vercel, Speed Insights will automatically track:
Build & Testing Results
✅ Build successful:
npm run buildproduces optimized production bundle✅ No linting errors introduced by changes
✅ No breaking changes to existing functionality
✅ Package.json properly updated with lock file
Next Steps for Deployment
vercel deployor git push to connected repository)/_vercel/speed-insights/script.jsTechnical Notes
injectSpeedInsights()function is called only once in the app, as requiredFiles Modified
All changes preserve the existing code structure and follow best practices for integrating Speed Insights with vanilla JavaScript applications on Vite.
View Project · Speed Insights
Created by juguk with Vercel Agent