An interactive, kid-friendly visualizer for the JavaScript event loop and execution model. Built with Svelte, Vite, Tailwind CSS, Three.js, and GSAP.
Kid Mode |
Pro Mode |
3D Engine |
- Kid Mode: Simple 2D SVG visuals with friendly metaphors (Task Robot, Magic Cloud, Speedy Lane, Waiting Line)
- Pro Mode: Technical 2D view with detailed logs, tooltips, and engine pipeline visualization
- 3D Engine: Immersive 3D visualization with realistic materials, smooth animations, and cinematic camera
Basic Scenarios:
- Two Logs: Demonstrates synchronous execution order
- Timer vs Promise: Shows microtask priority (Promises run before setTimeout)
- Fetch Robot: Illustrates Web API offloading and callback enqueueing
Advanced Scenarios:
- Microtask Chain: Shows how multiple Promises can starve macrotasks
- Nested Timeouts: Demonstrates FIFO macrotask queue ordering
- Async/Await: Visualizes async/await desugaring to microtasks
- DOM Click: Simulates event handler enqueueing
- Full keyboard navigation (Space/Enter to play/pause, Arrow keys to step)
- High-contrast theme with visible focus indicators
- Reduced motion support (respects
prefers-reduced-motion) - ARIA labels and live regions for screen readers
- Color + shape + icon encoding (not color-alone)
- Node.js 20.19+ (or 22.12+)
- npm 10+
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run previewOpen the dev server URL (typically http://localhost:5173) in your browser. Use the mode selector and scenario dropdown to explore different visualizations.
# Linting
npm run lint # Check for issues
npm run lint:fix # Auto-fix issues
# Formatting
npm run format # Check formatting
npm run format:write # Auto-format code
# Testing
npm run test:unit # Run Vitest unit tests
npm run test:e2e # Run Playwright E2E tests
npm run test:all # Run all testsAll tests include:
- โ Unit tests for simulation engine logic (event ordering, micro vs macro tasks)
- โ E2E tests for user flows (scenario selection, playback controls, mode switching)
- โ CI integration via GitHub Actions
- Project Plan: Overall roadmap and milestones
- Task Board: Development status and completed tasks
- Glossary: Kid Mode vs Pro Mode terminology
- Research Report: Deep dive into JS engines and event loop
- 3D Engine Guide: Complete 3D visualization documentation
src/
โโโ App.svelte # Main app component with controls
โโโ lib/
โ โโโ Stage.svelte # 2D SVG visualization stage
โ โโโ NewJSEngine3D.svelte # 3D visualization container
โ โโโ Controls.svelte # Playback controls
โ โโโ Legend.svelte # Visual legend
โ โโโ Token.svelte # Animated task tokens
โ โโโ sim/
โ โ โโโ engine.ts # Deterministic simulation runner
โ โ โโโ scenarios.ts # Predefined scenario scripts
โ โ โโโ types.ts # TypeScript types
โ โโโ jsengine3d/
โ โโโ JSEngine3D.ts # Core 3D engine
โ โโโ components/ # 3D component modules
โ โโโ CallStack.ts
โ โโโ WebAPIs.ts
โ โโโ MicrotaskQueue.ts
โ โโโ MacrotaskQueue.ts
โ โโโ EventLoop.ts
โ โโโ ExecutionFlow.ts
โโโ tests/
โ โโโ e2e/ # Playwright E2E tests
โโโ docs/ # Comprehensive documentation
MVP Complete โ All core features implemented:
- โ T1: Simulation engine with deterministic event loop
- โ T2: Visual layer integration (SVG + 3D)
- โ T3: Controls and narration
- โ T4: Kid Mode scenarios (basic + advanced)
- โ T5: Accessibility and responsiveness
- โ T6: Testing and quality assurance
- โ T7: Pro Mode with technical details
- โ T8: Tooling and CI/CD
- โ T9: Content and documentation
In Progress:
- T10: UI polish and enhancements
See docs/tasks.md for detailed status.
- Framework: Svelte 5
- Build Tool: Vite 7
- Styling: Tailwind CSS 4
- 3D Graphics: Three.js + cannon-es (physics)
- Animation: GSAP 3
- State Management: XState 5
- Testing: Vitest + Playwright
- Linting: ESLint + Prettier
- CI/CD: GitHub Actions
MIT โ see LICENSE
Contributions are welcome! Please read the documentation in docs/ to understand the architecture and workflow. Always work in a feature branch (never directly in main).
Made with โค๏ธ to help everyone understand JavaScript's magic โจ


