Performance optimizations: throttle scroll events, remove unused code, optimize loading #93
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 implements several targeted performance optimizations to improve page load speed, scrolling performance, and overall user experience on the website.
Changes
JavaScript Performance
Scroll Event Throttling
The scroll event handler was firing on every scroll event, potentially hundreds of times per second. This has been optimized by adding a throttle function that limits execution to once per 100ms, along with a passive event listener flag:
This reduces CPU usage during scrolling and provides a smoother experience, especially on lower-end devices.
Removed Unused ios.js Library
The ios.js library (~1.6KB) was being loaded on every page but was never actually used in the codebase. Removing it saves bandwidth and eliminates an unnecessary HTTP request.
Deferred Script Loading
Added the
deferattribute to the remaining JavaScript to ensure non-blocking execution and faster initial page render.CSS Performance
Removed Obsolete Vendor Prefixes
Cleaned up outdated vendor prefixes that are no longer needed in modern browsers:
-moz-font-feature-settings,-o-font-feature-settings,-webkit-font-feature-settings-webkit-transitionAll major browsers now support the unprefixed versions of these properties.
Optimized Animation Keyframes
Removed empty keyframe steps (20% and 75%) from the
home-intro-scrollanimation, reducing CSS size while maintaining the same visual result.Loading Performance
Async Font Loading
Implemented non-blocking font loading using the media="print" onload technique:
This prevents the Google Fonts CSS from blocking page render, improving First Contentful Paint by an estimated 100-200ms.
DNS Prefetch Hints
Added DNS prefetch hints for external domains (fonts.gstatic.com and cloud.umami.is) to enable parallel DNS resolution during page load, reducing connection latency.
Image Lazy Loading
Added
loading="lazy"attribute to 4 below-the-fold images that were previously loading eagerly, reducing initial page weight and bandwidth usage.Performance Impact
Before:
After:
Estimated Improvements:
Testing
Files Changed
assets/js/s.js- Added throttling and passive listener_layouts/home.html- Removed ios.js, added defer attribute_sass/_base.scss- Removed vendor prefixes_sass/_layout.scss- Cleaned animation keyframes_includes/head.html- Optimized font loading, added DNS hints_includes/home-work.html- Added lazy loading to imagesOriginal 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.