Performance Optimization
Performance is critical for mobile-first websites. Users on slower connections and less powerful devices need fast, responsive experiences. This project demonstrates several performance optimization strategies that work together to create a lightning-fast website.Why Performance Matters
Performance directly impacts business metrics:- User Experience: 53% of mobile users abandon sites that take over 3 seconds to load
- Conversion Rates: A 1-second delay can reduce conversions by 7%
- SEO: Google uses page speed as a ranking factor
- Accessibility: Faster sites work better on low-end devices and slow networks
Core Web Vitals (LCP, FID, CLS) are now key metrics for both user experience and SEO.
Efficient CSS Architecture
This project uses a lean, modular CSS architecture that minimizes file size and rendering overhead.Modular CSS Structure
The CSS is split into three focused files:index.html:20-22
- reset.css: Normalizes browser defaults (loaded once, cached forever)
- variables.css: CSS custom properties for theming (38 lines, minimal overhead)
- global.css: Component styles (764 lines, but no unused CSS)
CSS Variables for Efficiency
The project uses CSS custom properties for consistent, maintainable styling:variables.css:1-32
No Unused CSS
Every CSS rule in the project is actively used. There are no:- Unused utility classes
- Overridden styles
- Dead code from frameworks
Efficient Selectors
The project uses simple, performant CSS selectors:global.css:213-228
Simple class selectors like
.skill-card are faster than complex nested selectors like .section .container .card > .content.Modern CSS Features
The project leverages modern CSS for responsive layouts without media queries:global.css:276-280
global.css:433-436
Minimal JavaScript Approach
The entire site uses only 17 lines of JavaScript for menu functionality. This minimal approach has significant performance benefits.Complete JavaScript File
main.js:1-17
- No framework overhead (React, Vue would add 30-100KB)
- No build process required
- Instant parsing and execution
- No hydration delay
CSS-Driven Interactivity
Most interactions use CSS instead of JavaScript:global.css:185-193
global.css:230-243
Progressive Enhancement
The site follows progressive enhancement principles: it works without JavaScript and enhances with it.Desktop Navigation (No JS Required)
global.css:86-122
Progressive enhancement ensures your site works for all users, including those with JavaScript disabled or on slow connections where JS hasn’t loaded yet.
Font Loading Strategy
The project uses Google Fonts with performance optimizations:index.html:14-19
- preconnect: Establishes early connection to Google’s servers
- display=swap: Shows fallback font immediately, swaps when custom font loads
- Variable font: Single file supports multiple weights (100-800)
Font Display Strategy
- Show text immediately in a fallback font
- Swap to the custom font when it loads
- Never block text rendering waiting for fonts
Image Optimization Impact on Performance
Image optimization (covered in detail in the Image Optimization guide) is critical for performance:index.html:282-295
- WebP reduces image size by 25-35%
- Responsive images serve appropriate sizes
- Lazy loading defers offscreen images
Critical Resource Prioritization
The hero image usesfetchpriority="high" to prioritize loading:
index.html:54-60
The LCP metric measures when the largest visible element finishes rendering. For many sites, this is the hero image.
Responsive Design Performance
The project uses efficient responsive design patterns:Fluid Typography
global.css:20-24
global.css:142-147
clamp() function creates fluid typography that scales smoothly without JavaScript or multiple media queries.
Minimal Media Queries
The project uses only a few strategic media queries:variables.css:34-38
- Flexbox and Grid auto-layout
- CSS
clamp()for fluid sizing - Container queries for component-level responsiveness
JavaScript Loading Strategy
The script tag is placed at the end of the HTML:index.html:647
- HTML is fully parsed before script executes
- Page renders immediately (no render-blocking JS)
- DOM elements are available when script runs
For larger projects, consider using
defer or async attributes, but for small scripts like this, end-of-body placement is simplest and most reliable.Performance Budget
Here’s the approximate file size breakdown:| Resource | Size (Uncompressed) | Size (Gzipped) |
|---|---|---|
| HTML | ~14KB | ~4KB |
| CSS (all) | ~30KB | ~8KB |
| JavaScript | ~0.5KB | ~0.3KB |
| Above-fold images | ~25KB (WebP) | N/A |
| Total (initial load) | ~70KB | ~37KB |
With gzip compression and caching, returning visitors load only changed resources, often under 10KB.
Core Web Vitals Optimization
Largest Contentful Paint (LCP)
- Hero image optimized with
fetchpriority="high" - WebP format reduces image size
- Explicit dimensions prevent layout shift
- No render-blocking resources
First Input Delay (FID)
- Minimal JavaScript (17 lines)
- No heavy frameworks
- Simple event listeners
- Fast parsing and execution
Cumulative Layout Shift (CLS)
- All images have width/height attributes
- No dynamic content injection above the fold
- CSS reserves space for all elements
- Font display swap prevents layout changes
Best Practices Summary
Do:
- ✅ Keep CSS modular and minimal
- ✅ Use vanilla JavaScript when possible
- ✅ Implement progressive enhancement
- ✅ Optimize fonts with preconnect and display=swap
- ✅ Prioritize critical resources
- ✅ Use modern CSS features (Grid, clamp, container queries)
- ✅ Minimize media queries
- ✅ Set explicit image dimensions
Don’t:
- ❌ Add frameworks without clear benefits
- ❌ Include unused CSS
- ❌ Block rendering with JavaScript
- ❌ Load all fonts weights separately
- ❌ Ignore Core Web Vitals
- ❌ Skip compression and caching
Tools and Resources
- Lighthouse - Performance auditing tool
- WebPageTest - Detailed performance analysis
- Chrome DevTools Performance Tab - Runtime performance profiling
- web.dev/vitals - Core Web Vitals documentation
Regularly audit your site’s performance. What’s fast today may slow down as you add features. Maintain a performance budget and test on real devices.