Open
Conversation
# Vercel Speed Insights Implementation
## Summary
Successfully implemented Vercel Speed Insights for the ProScholarsTools static HTML website. Speed Insights will now track Core Web Vitals and performance metrics for all pages on the site.
## Changes Made
### 1. Added Speed Insights Scripts to All HTML Files (46 files)
Added the following Speed Insights initialization code before the closing `</body>` tag in all HTML files:
```html
<script>
window.si = window.si || function () { (window.siq = window.siq || []).push(arguments); };
</script>
<script defer src="/_vercel/speed-insights/script.js"></script>
```
**Files Modified:**
- All 39 HTML files in `/public/` directory (index.html, about.html, pricing.html, tools.html, contact.html, privacy.html, terms.html, thank-you.html, 404.html, GUMROAD_SETUP_GUIDE.html, and all 29 tool pages)
- All 7 HTML files in `/public/blog/` directory (blog index and 6 blog posts)
### 2. Updated Content Security Policy in vercel.json
Modified the Content-Security-Policy header to allow Speed Insights scripts and connections:
**Added to script-src:**
- `https://va.vercel-scripts.com` - for Vercel Analytics scripts
**Added to connect-src:**
- `https://vitals.vercel-insights.com` - for sending performance metrics to Vercel
## Implementation Details
This implementation follows Vercel's official documentation for HTML-based sites:
- No package installation required (Speed Insights is served from `/_vercel/speed-insights/script.js`)
- Scripts are loaded with `defer` attribute for optimal performance
- The initialization function (`window.si`) is set up before the script loads
- Scripts are added before the closing `</body>` tag to ensure DOM is ready
## Next Steps
To complete the Speed Insights setup:
1. **Enable Speed Insights in Vercel Dashboard:**
- Go to your project in the Vercel dashboard
- Navigate to the "Speed Insights" tab
- Click "Enable" to activate the feature
- This will add the necessary routes (`/_vercel/speed-insights/*`) after deployment
2. **Deploy to Vercel:**
```bash
vercel deploy --prod
```
3. **Verify Installation:**
- After deployment, visit any page on your site
- Open browser DevTools > Network tab
- Verify that `/_vercel/speed-insights/script.js` is loading successfully
4. **View Data:**
- After deployment and user visits, go to your Vercel dashboard
- Select your project
- Click the "Speed Insights" tab to view performance metrics
- Data will populate after a few days of visitor traffic
## Technical Notes
- The Speed Insights script is served from the same origin (`/_vercel/speed-insights/*`), which is already allowed by CSP's `script-src 'self'`
- The script automatically tracks Core Web Vitals (LCP, FID, CLS, FCP, TTFB, INP)
- No impact on existing functionality - the script loads asynchronously
- Privacy-compliant - follows Vercel's privacy and data compliance standards
- No cookies required - uses lightweight beacon API for metrics transmission
## Files Changed
- `vercel.json` - Updated CSP headers
- `public/**/*.html` - Added Speed Insights scripts (46 files total)
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.
Vercel Speed Insights Implementation
Summary
Successfully implemented Vercel Speed Insights for the ProScholarsTools static HTML website. Speed Insights will now track Core Web Vitals and performance metrics for all pages on the site.
Changes Made
1. Added Speed Insights Scripts to All HTML Files (46 files)
Added the following Speed Insights initialization code before the closing
</body>tag in all HTML files:Files Modified:
/public/directory (index.html, about.html, pricing.html, tools.html, contact.html, privacy.html, terms.html, thank-you.html, 404.html, GUMROAD_SETUP_GUIDE.html, and all 29 tool pages)/public/blog/directory (blog index and 6 blog posts)2. Updated Content Security Policy in vercel.json
Modified the Content-Security-Policy header to allow Speed Insights scripts and connections:
Added to script-src:
https://va.vercel-scripts.com- for Vercel Analytics scriptsAdded to connect-src:
https://vitals.vercel-insights.com- for sending performance metrics to VercelImplementation Details
This implementation follows Vercel's official documentation for HTML-based sites:
/_vercel/speed-insights/script.js)deferattribute for optimal performancewindow.si) is set up before the script loads</body>tag to ensure DOM is readyNext Steps
To complete the Speed Insights setup:
Enable Speed Insights in Vercel Dashboard:
/_vercel/speed-insights/*) after deploymentDeploy to Vercel:
Verify Installation:
/_vercel/speed-insights/script.jsis loading successfullyView Data:
Technical Notes
/_vercel/speed-insights/*), which is already allowed by CSP'sscript-src 'self'Files Changed
vercel.json- Updated CSP headerspublic/**/*.html- Added Speed Insights scripts (46 files total)View Project · Speed Insights
Created by rogaareef with Vercel Agent