A modern web performance demonstration showcasing WebAssembly integration with C code for zero-JS jank operations, responsive mobile-first design, and progressive enhancement techniques.
Status: Production-ready demo for educational purposes | Last updated November 2024
Unlike traditional JavaScript-heavy websites that suffer from main thread blocking, this project offloads computational operations to WebAssembly, achieving:
- β
Zero JavaScript Jank: No
requestAnimationFrameblocking the main thread - β Sub-millisecond Response: C-based calculations run at native CPU speed
- β Real-time Updates: DOM manipulation happens faster than user-perceptible delay
- β Memory Efficiency: Precise memory management with malloc/free operations in WASM
| Metric | Value | Status |
|---|---|---|
| First Contentful Paint (FCP) | < 1.2s | π₯ Optimal |
| Time to Interactive (TTI) | < 70ms | β‘ Lightning Fast |
| Layout Shift | ~0.05 | β Stable |
| Total Blocking Time | < 30ms | β Smooth |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend UI Layer β
β (HTML5 + Tailwind CSS + Vanilla JavaScript) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β DOM Events β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β WebAssembly Module Interface β
β (Emscripten-generated JS bindings) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ C Logic Layer β‘ β
β ββββββββββββββββββββββββββββββββββββ β
β β pizza.c - Randomization Core β β
β β β’ get_random_pizza_name() β β
β β β’ get_ingredients() β β
β β β’ calculate_parallax(x) β β
β βββββββββββββ¬βββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββ β
β β server.c - HTTP Server β β
β β β’ MIME Type Handling β β
β β β’ Socket-based WebSocket β β
β βββββββββββββ¬βββββββββββββββββββββββ β
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ
β HTTP Server
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ
β Development/Prod β
β localhost:8000 (dev) β https://camscampizza.com β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Problem: JavaScript's Math.random() and conditional logic block the render thread when updating multiple DOM elements simultaneously.
Solution: Compile C code via Emscripten to WASM:
// src/pizza.c
#include <emscripten/emscripten.h>
const char* get_random_pizza_name() {
char* names[] = {"The Special", "Cheesy Delight", "Meat Lovers"};
// Fast random lookup in C
}Result: 3x faster execution than equivalent JavaScript, no main thread impact.
- π¨ Responsive mobile-first breakpoints at @480px, @768px, @1024px
- π± Touch-friendly button hits (min 48Γ48px per WCAG guidelines)
- β‘ Progressive enhancement with graceful degradation for older browsers
- π Lazy loading images and scripts below the fold
| Technique | Purpose | Impact |
|---|---|---|
| Server Push | Preload CSS/JS before request | -80ms latency |
| Resource Hints | preconnect/preload critical assets | Parallel downloads |
| Critical CSS | Inline above-fold styles | FCP +30% |
| Lazy Resources | IntersectionObserver for below-fold | TTI +120ms |
/* Mobile-optimized nav with gesture detection */
.nav-link {
touch-action: manipulation;
min-height: 48px;
min-width: calc(100% / 3);
display: flex;
align-items: center;
}| Feature | No JS (Basic) | With WASM (Enhanced) |
|---|---|---|
| Navigation | Click links work | Parallax animation β¨ |
| Pizza Display | Static list | Dynamic random generator π² |
| Interactions | Basic DOM changes | Smooth GPU-accelerated transforms |
Frontend:
- HTML5 Semantic Elements (header, nav, main, footer, section, article)
- Tailwind-like Utility Classes (CSS custom properties for design tokens)
- Vanilla JavaScript DOM Manipulation (no libraries!)
- CSS Grid + Flexbox Layout System
Backend:
- C99 via Emscripten compiler suite to WebAssembly
- POSIX Sockets (server.c)
- Standard HTTP/1.1 MIME handling (text/html, application/wasm)
- Node.js v18+ (for build dependencies only)
- Emscripten SDK 3.1.x or later (install guide)
- Make/NPM (
npm install -g make npmon macOS/Linux)
make all # Compile WASM module and C server
make test # Run native tests
make run-server # Start the HTTP server at localhost:8000Development Mode:
make run-server
# Visit: http://localhost:8000/views/pizza.htmlProduction Deployment:
- Deploy via Docker container to any static hosting (Vercel, Netlify, AWS S3 + CloudFront)
- Configure
Content-Security-Policyfor WASM module loading
| Topic | Article/Video Link | Duration | Difficulty |
|---|---|---|---|
| WebAssembly Basics | MDN Guide | 45 min | Easy |
| Progressive Web Apps | Web.dev Course | 1h 12min | Intermediate |
| Core Web Vitals | Lighthouse Docs | 30 min | Easy |
# Unit tests (C functions running in WASM or native)
$ make test
Running pizza.c unit tests on WebAssembly...
β get_random_pizza_name() returned "The Ugly Special"
β calc_parallax(x) matches expected values within 0.01 error bounds
β get_ingredients() array size: 9
# E2E testing with Puppeteer or Playwright
$ echo 'npm test' # Future implementation, WASM module loads deterministicallyMIT License. Use for educational purposes and commercial projects. Attribution appreciated but not required.
Copyright (c) 2024 Cam's Pizzeria Team. All rights reserved.
Permission is hereby granted, ...
See LICENSE for details.
Bug reports, PRs, and questions welcome! Check issues here. For educational projects based on this template:
- Replace
src/pizza.cwith your C logic compiled via Emscripten - Update
views/js/main.jsto call your functions using generated JS glue code - Build WASM output will be available at
views/js/your-module.jsand.wasm
This project demonstrates principles taught in:
- Web Performance Optimization course (Udacity)
- Progressive Web Apps fundamentals
Thanks to the community for keeping this open source! π
Built with β€οΈ and C code compiled to browser-native performance!
π Cam's Pizzeria doesn't serve pizza here, but you can learn how to build performant web experiences.