Performance improvements: Optimize scroll events, reduce HTML size, improve resource loading #91
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.
Overview
This PR addresses performance bottlenecks in the website by optimizing scroll event handling, reducing HTML payload size, and improving resource loading efficiency. These changes result in faster page loads, smoother scrolling, and better overall user experience.
Changes Made
1. Scroll Event Throttling (
assets/js/s.js)The scroll event handler was executing on every single scroll event, causing unnecessary performance overhead. This has been optimized by:
{ passive: true }flag to allow browser optimizations for better scroll performanceMath.max()of 5 DOM properties with singledocument.documentElement.scrollHeightaccessBefore:
After:
2. JavaScript Externalization (
pewpew.html)Moved 7.6KB of inline JavaScript to an external file (
assets/pewpew/demo.js) with deferred loading. This provides several benefits:Impact: pewpew.html reduced from 21,122 bytes to 13,512 bytes (36% reduction)
3. Favicon Optimization (
_includes/head.html)Replaced 3KB base64-encoded favicon with an external file reference. The base64 encoding was adding unnecessary bytes to every HTML page load.
Before:
After:
Impact: head.html reduced from ~4,900 bytes to 1,864 bytes (62% reduction)
4. Resource Loading Optimization
Added preconnect hints for Google Fonts to reduce DNS lookup latency:
This allows the browser to establish connections in parallel while parsing HTML, reducing overall font loading time.
Performance Impact
Testing & Validation
Files Changed
_includes/head.html- Favicon and preconnect optimizationsassets/js/s.js- Scroll throttling and DOM optimizationassets/pewpew/demo.js- NEW: Externalized JavaScriptpewpew.html- Removed inline script, added deferred external scriptThese surgical, minimal changes deliver significant real-world performance improvements while maintaining code quality and security standards.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.