AI summary by TwinMind
Svelte Hot Takes - Reacting To Web Hot Takes from Rich Harris
Theo - t3․gg
1h 1m 7s
Introduction & Context
- Rich Harris delivering talk "In My Humble Opinion" at Vercel event
- Collection of connected thoughts on front-end development trends
- Encouraged by Vercel to be as spicy as possible with opinions
- Disclaimers: opinions are humble, some ideas from smarter people, not speaking for Vercel team
JavaScript Frameworks Aren't the Root Problem
- Pushback against thought leadership blaming JavaScript frameworks for web problems
- Web sucks because of capitalism, attention economy, data-driven monetization, algorithmic slavery
- Framework authors should focus on empowering developers through education, documentation, diagnostics, sensible defaults
- Performance data shows only Astro and Svelte score above average website on Core Web Vitals
- Astro: explicitly markets for content sites with less interactivity
- Selection bias: developers choosing performance-focused frameworks care more about performance
- Next.js: 90,000 tracked sites, Nuxt: 50,000, Astro: 500, Svelte: 1,400
Zero Kilobytes JavaScript Critique
- "Zero kilobytes of JavaScript" not inherently good goal
- Real goal: meet user needs, sometimes business needs
- Performance sometimes factor, but JavaScript essential for best possible performance
- Lighthouse as diagnostic tool, not scorecard - good Hart's law example
- Learn.svelte.dev example: poor Lighthouse score due to necessary work (downloading Svelte, SvelteKit, starting dev server)
- Pre-loading JavaScript can make numbers look worse but user experience better
Progressive Enhancement Philosophy
- Sites that can work without JavaScript should work without JavaScript
- JavaScript necessary for best user experience AND sometimes can't rely on JavaScript
- "Everyone has JavaScript, right?" - subway station example of losing connectivity before JS loads
- Most web apps should be mostly functional without JavaScript
- Google Calendar example: could work without JS but development cost not worth it
- SvelteKit: server render everything by default, easy forms without JavaScript
- Web archival concerns: Kim Kardashian Instagram example showing degradation over time (2014-2020)
Single Page Apps vs Multi Page Apps
- Definitions: MPA = traditional website with server-rendered pages, SPA = client-side routing without document unload
- MPA claims: faster (no JS), more accessible, less buggy, work without JS
- SPA claims: faster subsequent navigation, unified development model, state preservation, smooth transitions
- Modern frameworks (Next, Remix, SvelteKit) don't suffer from early SPA problems
- "MPAs are dead" - Astro killed them by adding client-side routing
- SvelteKit uses client-side routing by default with regular <a> tags, fallback to full page navigation on deployment detection
Domain Specific Languages (DSLs)
- DSLs get bad rap but are good (HTML, CSS, JSON, SQL, regex all DSLs)
- JavaScript event-driven vs UI state-oriented impedance mismatch
- React, hooks, signals attempt to resolve this contradiction
- Svelte augments HTML with state/control flow, CSS with scoped styles, JavaScript with reactivity
- Crucial caveat: must be honest about DSLs - .svelte files create liminal space where normal programming rules suspended
Co-location Critique
- Remix/early Next.js pattern of server code co-located with client code in same file
- Problems: non-standard JavaScript semantics, tree-shaking actually changing semantics
- Security risks: server code potentially in client bundle, source maps expose server code
- SvelteKit solution: co-locate in directories not files
- +page.server.js for server code, +page.svelte for client code
- Files with .server.js suffix cannot be imported into client code
- Type safety across network boundary
Client vs Server Code Execution
- Code should run as close to user as possible: edge > central server, on-device > edge
- Exceptions: database access, sensitive information
- Examples: shopping cart updates, GitHub markdown preview
- Resilience concerns: Amtrak/subway connectivity issues
- React Server Components concerns: default server rendering with opt-in client components
- Risk of over-correction: paranoid about JavaScript leading to slower, less resilient apps
RPC (Remote Procedure Call) Critique
- RPC concept from 1970s: call server functions as if local
- 1988 critique still relevant: serialization issues, network vs logic errors, hidden implementation
- Modern renaissance: server functions in Solid, Qwik, theoretical frameworks
- Ergonomics nice but dangerous: creates HTTP endpoints that look like private functions
- Security concerns: SQL injection example, source maps exposing server architecture
- SvelteKit decision: said no to this pattern, built-in CSRF protection instead
Build Steps Defense
- Build steps primarily benefit users, not developers
- Benefits: minification, module combination, unused code removal, image optimization, asset hashing, type checking
- People complaining about DX over UX overlap with people wanting to remove build tools
- SvelteKit docs example: code snippets type-checked against source at build time
- Pre-rendering for instant content delivery vs on-demand rendering delays
AI Future Speculation
- AI might change development jobs beyond recognition
- Current framework debates might become irrelevant
- Analogy: like arguing about punch card hole-making implements
- Encouragement: have interesting debates, share ideas, don't take too seriously, have fun building
