JSConf
Re-rendering interfaces through an in-memory virtual DOM prevents layout thrashing and eliminates mutable bugs because traditional templates merely separate technologies rather than concerns.
AI-assisted summary of Pete Hunt: React - Rethinking Best Practices (updated) - JSConf.Asia 2013 — original source. Check the original for full context.
Source published:
Key ideas
- React rejects traditional template-based separation of concerns, arguing that splitting HTML templates and JavaScript display logic merely separates technologies while breaking module cohesion. (5:18)
- The framework models UI components as idempotent functions that conceptually re-render the entire application upon any data change, emulating the deterministic simplicity of 1990s server-rendered architectures. (16:55)
- To achieve 60 FPS performance and avoid costly layout thrashing on the native DOM, React introduces an in-memory Virtual DOM that diffs updates and flushes batched mutations to the browser. (22:23)
- Isomorphic JavaScript rendering in Node.js allows React to emit static HTML for fast initial loads and SEO, hydrating existing DOM elements with event listeners on the client without recreation. (30:41)
- The presentation debuts the React Chrome Developer Tools, enabling developers to inspect and manipulate semantic component hierarchies rather than navigating raw browser DOM trees. (35:17)
Detailed notes
## Background Published on YouTube by JSConf on January 3, 2014, this talk features Pete Hunt speaking at JSConf.Asia 2013 in the Philippines. Hunt, a member of the React core team at Facebook and engineer on Instagram.com, addresses the initial skepticism surrounding React's open-source release by exploring three controversial design decisions: abandoning templates in favor of components, full-page re-rendering semantics, and an in-memory Virtual DOM architecture.
## TL;DR Pete Hunt defends React's unconventional architectural philosophy by reframing common front-end practices through classical software engineering principles. Rather than splitting markup and display logic across different file types—which he argues separates technologies rather than concerns—React unifies them into cohesive, reusable JavaScript components. Hunt explains that treating UI components as idempotent functions and re-rendering on data updates radically simplifies mental models, while the in-memory Virtual DOM ensures high performance by eliminating layout thrashing and batching real DOM mutations. The presentation demonstrates 60 FPS mobile performance, touches on isomorphic server-side rendering, and concludes with an unveiling of the original React Chrome Developer Tools.
## Atmosphere & style The presentation carries the measured, persuasive tone of an engineer defending a radical paradigm against an initially hostile and skeptical industry. Hunt maintains a calm, dryly humorous demeanor, acknowledging early disbelief with slides of cynical tweets before methodically dismantling front-end dogmas using computer science fundamentals. The energy is intellectually clarifying and confident, shifting from pragmatic architectural debate to palpable excitement during live performance demos and the reveal of the Chrome DevTools extension.
## Bulletin - [05:18](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=318s) React rejects traditional template-based separation of concerns, arguing that splitting HTML templates and JavaScript display logic merely separates technologies while breaking module cohesion. - [16:55](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1015s) The framework models UI components as idempotent functions that conceptually re-render the entire application upon any data change, emulating the deterministic simplicity of 1990s server-rendered architectures. - [22:23](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1343s) To achieve 60 FPS performance and avoid costly layout thrashing on the native DOM, React introduces an in-memory Virtual DOM that diffs updates and flushes batched mutations to the browser. - [30:41](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1841s) Isomorphic JavaScript rendering in Node.js allows React to emit static HTML for fast initial loads and SEO, hydrating existing DOM elements with event listeners on the client without recreation. - [35:17](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=2117s) The presentation debuts the React Chrome Developer Tools, enabling developers to inspect and manipulate semantic component hierarchies rather than navigating raw browser DOM trees.
## Key takeaways - [00:19](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=19s) React was open-sourced in May 2013 as a focused view-layer library designed to drop into existing stacks, despite initial skepticism from the web community. - [03:43](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=223s) Software maintainability is evaluated by coupling and cohesion; cascading changes across files indicate fragile, tightly coupled architectures. - [05:18](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=318s) Templates and display logic are inherently coupled because both exist to translate application state into DOM structures; separating them into different files sacrifices cohesion. - [07:35](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=455s) Templating languages and HTML directives reinvent programming language mechanics poorly, whereas React components leverage native JavaScript loops, scope, and composition. - [13:12](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=792s) React components avoid XSS vulnerabilities by using programmatic DOM constructors that automatically escape data rather than concatenating raw HTML strings. - [15:13](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=913s) JSX provides an optional, compile-time syntax extension that gives designers template-like syntax while maintaining the full computational power of JavaScript. - [16:55](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1015s) Frontend bugs largely stem from managing mutable state over time; React counters this by re-rendering declarative component trees whenever data changes. - [20:36](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1236s) Mutable state is strictly isolated through methods like getInitialState, and updates are centralized through setState to eliminate complex change-tracking listeners. - [22:23](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1343s) Direct native DOM manipulation causes performance bottlenecks; React resolves this by diffing an in-memory Virtual DOM and batch-applying minimal DOM operations. - [23:51](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1431s) React's architecture mirrors 3D game engines like Doom 3, using components to produce an intermediate scene representation (the Virtual DOM) that is rendered out to the browser. - [25:31](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1531s) A synthetic event system provides cross-browser event normalization down to IE8 and reduces memory overhead through automated event delegation at the root. - [29:11](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1751s) Virtual DOM reconciliation is fast enough to achieve a fluid 60 FPS on mobile hardware without relying on native CSS transitions or overflow scrolling. - [30:41](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1841s) Server-side rendering with Node.js solves crawler SEO limitations and delivers fast first-page paints before client-side scripts hydrate the DOM. - [32:44](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1964s) Decoupling components from the DOM allows alternative targets like HTML5 Canvas and SVG, off-thread rendering inside Web Workers, and fast unit testing without headless browsers. - [37:04](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=2224s) React provides lifecycle methods such as componentDidMount and componentWillUnmount to seamlessly integrate with legacy codebases and jQuery plugins.
## Detailed walkthrough ### [00:19](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=19s) Challenging Conventional Wisdom and Rethinking Best Practices
Pete Hunt opens his presentation by introducing React, a JavaScript library developed at Facebook that had been open-sourced earlier that year in May at JSConf US. React's debut was not met with universal applause; rather, as Hunt recalls with dry humor, the community initially met it with disbelief and sarcastic reactions. Displaying a slide of a famously skeptical tweet from the launch, Hunt points out that it was decidedly not intended as a compliment. React defied long-standing front-end conventions, prompting developers to recoil at first glance. Rather than asking for blind acceptance, Hunt asks the audience to withhold judgment and give the concepts an open mind for just five minutes, emphasizing that React is not an untested academic experiment, but a proven tool running major production applications across large engineering teams at Facebook and Instagram.
Hunt clarifies that the objective of his talk is not to provide a basic step-by-step coding tutorial on how to construct a React app, since developers can easily access guides, docs, and videos online for that. Instead, his focus is on the fundamental design decisions that shape React: explaining why Facebook engineered it this way, what problems it solves, and how engineers can adopt those architectural insights in their own codebases even if they never use React itself. At its core, React is a library for creating user interfaces, which specifically means rendering UI and handling browser events. In traditional architectural terms, it occupies the "V" in MVC (or doubles as the controller depending on how one defines the term). A key design requirement was seamless interoperability: React was specifically designed to drop gracefully into existing technology stacks, allowing teams to adopt it incrementally on small features and gradually expand its footprint as they saw results.
- React was publicly open-sourced in May 2013 at JSConf US to widespread developer skepticism. - It is deployed heavily across production codebases at Facebook and Instagram. - React positions itself strictly as a UI library (the "View" in MVC) rather than a monolithic full-stack framework. - Pete Hunt urged the audience: “So we basically challenged some kind of conventional wisdom with React, so as we talk about it, I'd appreciate it if you gave it five minutes.”
[01:51](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=111s) Three Core Themes and the Question of Separation of Concerns
Hunt outlines the roadmap for the rest of his talk, which centers around three controversial topics. The first is an architectural prerequisite: combining DOM generation directly with display logic inside components rather than relying on a traditional templating system. The second topic examines React's high-level application design, specifically the radical idea of re-rendering the entire application whenever data changes to make development predictable and enjoyable. The third topic covers React's unique ground-up implementation, including its custom, lightweight virtual representation of the DOM and event handling system.
Transitioning to the first topic—building components instead of templates—Hunt surveys the room, noting that virtually everyone has built user interfaces with JavaScript and that many rely on client-side templating libraries such as Handlebars, or use similar template systems on the server. To the traditional front-end mindset, mixing markup and display logic inside a component sounds like an unforgivable anti-pattern. Developers defend templates primarily on the grounds of "separation of concerns," where a templating engine accepts a data structure, merges it with an HTML document annotated with special directives, and outputs static markup. However, Hunt challenges whether developers actually understand what they mean when they invoke that phrase. He contends that "concerns" is an ambiguous, ill-defined catchphrase in web development, and suggests evaluating software design through established software engineering metrics: coupling and cohesion.
- The talk covers three key areas: discarding templates in favor of components, full re-rendering on data updates, and a custom virtual DOM implementation. - Templating engines typically combine raw data structures with marked-up HTML strings to generate static DOM output. - Pete Hunt noted, “Separation of concerns really isn't a specific term, right, like what are concerns, it's very ill-defined.”
[03:43](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=223s) Coupling, Cohesion, and the Pain of Cascading Changes
Hunt turns to formal software engineering definitions to explain what makes software maintainable. Coupling refers to the degree of mutual interdependence between different modules in a program. In day-to-day software development, bugs or features that can be resolved within a single function or class are straightforward: an engineer diagnoses the issue, writes a fix, perhaps adds a unit test, and moves forward. The real operational nightmares arise when touching one module triggers a ripple effect across multiple unrelated files. Hunt labels these "cascading changes," identifying them as the telltale symptom of tight coupling, which quickly turns large codebases into an unmaintainable mess.
The second critical metric is cohesion: the degree to which elements inside a single module genuinely belong together. Hunt points out that an engineering team could build the most decoupled system imaginable, but if the boundaries of those modules do not align with clear functional responsibilities, the architecture remains unmaintainable. When functionality is fragmented across disparate files, developers waste hours hunting through the system just to figure out where a specific change must be implemented.
```mermaid flowchart TD accTitle: Coupling and Cohesion Dynamics accDescr: Flowchart contrasting the behavior of tightly coupled cascading changes with cohesive isolated modules. subgraph TightlyCoupled["Tight Coupling: Cascading Changes"] A["Change in Module A"] -->|"Forces updates"| B["Module B (Broken State)"] B -->|"Forces updates"| C["Module C (Broken State)"] end subgraph HighCohesion["High Cohesion: Localized Updates"] D["Focused Component Module"] -->|"Encapsulates"| E["Self-Contained Logic & View"] E -->|"Safe, localized edits"| F["Single Unit Test Verification"] end ```
- Low coupling minimizes cascading changes across unrelated program files. - High cohesion ensures that related responsibilities and data stay packaged together within sensible module boundaries. - Pete Hunt explained, “The really painful bugs and features are the ones that you have to make changes to multiple modules, so we like to call these cascading changes, and they're a symptom of tight coupling.”
[05:18](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=318s) Separating Technologies vs. Separating Concerns
Hunt takes aim at the sacred cow of web development: the belief that putting markup in an HTML template file and display logic in a JavaScript file achieves true separation of concerns. This paradigm encompasses not only traditional string-based templates but also HTML directive frameworks like AngularJS. On the surface, placing display logic in a `.js` file and markup in a `.html` template feels clean—developers assume that behavioral updates happen in JavaScript while visual design changes occur in the template. Hunt argues this is a profound misunderstanding because an invisible, tight coupling always exists between the template and its controller.
To illustrate, Hunt uses the example of building a zebra-striped table with alternating row colors. To alternate colors, the developer often has to calculate row styling inside the display logic and pass that information via a view model into the template. The moment the visual presentation changes, the developer is forced to edit both the template and the JavaScript view model to keep the data contract in sync. Because display logic and markup both exist to manipulate and render DOM nodes based on application state, they are inherently coupled. However, because they are doing the exact same job—transforming application state into DOM structures—they are naturally cohesive. By splitting them into separate files based purely on language syntax, developers are not separating concerns at all; they are merely separating technologies, and doing so at the cost of cohesion.
```mermaid flowchart TD accTitle: Coupling in Traditional Web Templates accDescr: Flowchart contrasting separated technologies with shared DOM responsibilities. subgraph TechSplit["Separation of Technologies"] A["Display Logic (JavaScript)"] B["Template Markup (HTML)"] A <-->|"Implicit coupling via view model"| B end subgraph SharedRole["Shared Cohesive Purpose"] C["DOM Data Structures"] A -->|"Manipulates"| C B -->|"Renders to"| C end ```
- Display logic and markup are inherently tightly coupled through the shared view model and DOM state. - Templates and JavaScript display logic share high cohesion because both exist to translate state into DOM nodes. - Pete Hunt asserted, “So what we're actually doing when we're using templates and display logic and separating those out, we're separating technologies, not concerns.”
[07:35](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=455s) The Limitations of Underpowered Templates and Reinvented Languages
Because template systems separate technologies rather than concerns, they deliberately restrict the developer to an underpowered, domain-specific syntax. Hunt uses Handlebars—which he acknowledges as a high-quality, performant library—to illustrate the architectural limitations of templates. When developers attempt to reuse markup in Handlebars, they rely on "partials," such as an avatar or profile picture component used across a social network. The partial is effectively copy-pasted into the parent template at execution, automatically inheriting all variables in the parent's ambient scope. This creates invisible dependencies: modifying a partial requires manually inspecting every single call site in the application to ensure required variables exist and naming collisions do not occur. Similarly, control-flow helpers like `{{#each}}` break down whenever an engineer needs non-trivial iteration, such as rendering two distinct elements per item, exposing the rigid ceiling of a language that lacks the full capabilities of JavaScript.
The alternative approach popular in the ecosystem—augmenting HTML documents with custom directives, as seen in AngularJS—suffers from an even more insidious flaw. By attempting to make static documents interactive, framework authors are effectively attempting to invent an entirely new programming language on top of HTML. However, because they do not openly admit they are designing a programming language, they end up reinventing basic language mechanics that already exist in JavaScript. Displaying an excerpt from the AngularJS directive documentation, Hunt highlights the dense array of bespoke concepts and vocabulary terms developers must memorize just to replicate scoping, binding, and execution flows that are already built-in, native features of JavaScript.
- Handlebars partials introduce fragile implicit scope dependencies across call sites. - Templating helpers like `{{#each}}` lack the expressive power of standard language loops and conditionals. - HTML directives effectively invent an ad-hoc, incomplete programming language embedded in markup attributes. - Pete Hunt observed, “Now the problem with this is that the way that people are building these abstractions on the web today, they don't accept that they're building a new programming language, so you have to invent a lot of new concepts that are slightly incompatible with, you know, a real programming language that we have today, JavaScript.”
[10:32](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=632s) Rethinking Concerns: Components Over Framework Language
Pete Hunt argues that contemporary frameworks and libraries make the mistake of dictating how developers ought to separate concerns. In reality, developers do not think of their applications in terms of models, views, and controllers; they think in concepts native to the product itself, such as user profiles, navigation bars, and timeline posts. Because of this mismatch, Hunt insists that a framework should merely supply tools to express the application in the language of its own problem domain.
React’s answer to this challenge is the component: a highly cohesive, loosely coupled building block for user interfaces. Instead of relying on a restricted templating language, React merges DOM generation with display logic, giving developers the uninhibited power of JavaScript. Reusing code or handling events does not require inventing new abstractions like partials; it simply means writing a regular JavaScript function. As a result, developers can immediately run linters, write unit tests, and leverage existing JavaScript tooling. Composition becomes the primary architectural mechanism, allowing developers to construct rich interfaces out of smaller, reusable components, while keeping the door open for standard JavaScript expressions inside the display layer.
As Pete Hunt states: > “So we think that the framework of the library you're using should just give you tools for you to express your program in the language of your problem domain, rather than the language of the framework itself.”
- React components unify DOM generation and display logic into a single cohesive unit. - Code reuse relies on standard JavaScript functions rather than specialized framework concepts like template partials. - Components are composable, reusable, and unit-testable because they operate as isolated units.
[13:12](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=792s) Combating Spaghetti Code and XSS Risks
Addressing engineers with backgrounds in legacy systems, Hunt tackles the immediate skepticism that combining markup generation with logic inevitably leads to spaghetti code. He clarifies that React does not advocate a return to obsolete practices like calling database queries directly inside rendering routines. Instead, the burden falls on professional discipline: developers must keep components small and restrict them strictly to display logic. Any language or library can be abused into spaghetti code, so engineers must use sound design principles.
Another common fear is security, specifically cross-site scripting (XSS). Early templating solutions gained favor precisely because concatenating raw HTML strings invited injection vulnerabilities—a rogue user-supplied string could insert a script tag, steal session cookies, and impersonate the user. React mitigates this risk by never manipulating raw strings. Instead, it uses `React.DOM`, an API that builds a programmatic representation of the DOM. For instance, invoking `React.DOM.a` takes an attributes object (such as an `href` pointing to an Instagram profile) followed by child nodes or text. Crucially, this library automatically escapes all data passed into it, preventing injection by default.
When confronting the spaghetti code debate, Pete Hunt puts the responsibility directly on the engineer: > “So my answer to kind of asking about spaghetti code when we combine DOM generation and display logic is just don't write spaghetti code, keep your components small and only put display logic in components.”
[15:13](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=913s) JSX: Bridging Designers and JavaScript
Writing raw functional calls like `React.DOM.a(...)` works well for programmatic logic, but it creates friction with visual designers. Designers excel in Photoshop and HTML mockups, but they have no interest in maintaining nested JavaScript function calls; conversely, engineers do not want to spend hours fine-tuning CSS box shadows when they could hand off a nearly finished interface for pixel-pushing. To bridge this divide, the React team built JSX, an optional syntax extension that brings familiar HTML-like syntax directly into JavaScript files.
Hunt emphasizes that JSX is completely decoupled from React's core requirements: developers can use React without JSX, and JSX can even be adapted for tools outside of React. The JSX preprocessor simply translates XML-style markup into identical `React.DOM` function invocations under the hood. This offers teams the readability and accessibility of conventional templates alongside the computational power and functional programming paradigms of JavaScript.
As Pete Hunt characterizes the compromise: > “So we like to think of it like this: the accessibility of templates and the power of JavaScript.”
```mermaid flowchart LR accTitle: JSX Compilation Flow accDescr: Diagram showing how JSX expressions transform into React.DOM function calls and finally into safe DOM representations. subgraph Authoring["Authoring Phase"] A["JSX Syntax<br/>(HTML-like tags)"] end subgraph Transformation["Compilation"] B["React.DOM Calls<br/>(Pure JavaScript)"] end subgraph Output["Runtime Engine"] C["Virtual DOM Tree<br/>(Escaped & Sanitized)"] end
A -->|"JSX Compiler"| B B -->|"Execution"| C ```
[16:55](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1015s) Re-rendering and Managing State Over Time
Transitioning to React's most controversial and defining mechanism, Hunt highlights the fundamental headache of frontend engineering: state. Unlike backend systems where code typically takes inputs, returns outputs, and satisfies deterministic unit tests, frontends deal with unpredictable user inputs, heterogeneous runtimes, and a massive mutable DOM. The ultimate culprit behind interface bugs is mutable data changing over time.
To reinforce this point, Hunt references computer scientist Edsger W. Dijkstra, who observed that human minds are well-equipped to reason about static relations, but struggle significantly to track processes that evolve across time. Dijkstra argued that software should minimize the conceptual gap between static code and dynamic runtime execution. Hunt maps this insight onto server-rendered architectures circa 1999: in early PHP workflows, adding a to-do item did not require searching the DOM for every counter or list element to mutate them individually. The client submitted the item, the server wrote to the database, queried the new state, and re-rendered the entire page from scratch at that single point in time.
React adopts that exact conceptual model on the client. When data changes, React reruns the render methods and conceptually throws out the old view representation to compute a new one. React components act as idempotent functions mapping dynamic state into a predictable UI snapshot, making them dramatically simpler to reason about, maintain, and unit test without fragile end-to-end DOM scripting. Hunt then introduces a clicker component to demonstrate this re-render concept in action.
Quoting Edsger W. Dijkstra on human cognition and system state, Pete Hunt reads: > “Our intellectual powers are rather geared to master static relations and our power to visualize processes involving in time are relatively poorly developed.”
Pete Hunt summarizes the core philosophy of React components: > “Said another way, React components are just idempotent functions that describe your UI at any point in time, just like a server-rendered app.”
- Frontend complexity stems from mutable state and data changing over time across asynchronous events. - Server-rendered web apps from the late 1990s avoided mutation tracking by regenerating the complete page response per request. - React treats UI components as idempotent functions: given the current input state, they produce the entire corresponding UI representation.
[20:36](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1236s) Isolating State and Declarative Updates
Pete Hunt walks through the architectural philosophy behind React's component state. Examining a counter component, he emphasizes that nowhere in the code does an engineer search the DOM to manually replace an element's text. Instead, the `render` method declaratively describes what the component should look like at any point in time. It avoids prescribing both an initial state and a distinct sequence of manual mutation instructions; `render` is simply called whenever data changes. Addressing the common engineering adage, Pete acknowledges that while data changing over time is a notorious source of bugs, dynamic applications fundamentally require state. React's solution is to isolate that mutable state as tightly as possible. In the example shown, the sole piece of mutable data is an explicit `count` variable initialized to zero.
Predicting how an application evolves over time becomes straightforward because state transitions are concentrated. Developers debugging an unfamiliar codebase do not need to trace complex event graphs; they can simply search for `setState` to locate every single state mutation point. By re-rendering whenever data changes, the interface is guaranteed to remain synchronized without relying on computed properties, change-tracking listeners, two-way data binding, or expensive model dirty checking.
Pete Hunt summarizes the shift in mental model: “Nowhere do we search for this DOM node and rewrite the count; we declaratively say, hey, this render method says what this component should look like.”
- Mutable state is isolated down to explicit properties declared in methods like `getInitialState`. - State transitions are consolidated entirely around calls to `setState`. - Eliminates manual change-tracking registrations, computed binding plumbing, and dirty-checking loops.
[22:23](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1343s) The Cost of Real DOM and the Virtual DOM Solution
Re-rendering entire views upon every single change initially strikes developers as a terrible idea. If an application were to tear down and reconstruct the real browser DOM on every keystroke or update, severe user-experience penalties would follow immediately. Form focus would be destroyed, in-progress comment text would vanish, scroll positions would reset, and pages would suffer from flashes of unstyled content (FOUC). Furthermore, manipulating the native browser DOM is inherently slow.
To overcome the performance wall of the native browser DOM while preserving the simplicity of a re-render paradigm, React introduces the Virtual DOM. The Virtual DOM is an in-memory representation of the UI tree optimized for minimal memory footprint and raw execution speed. During an update cycle, React re-invokes the component's `render` method to generate a new Virtual DOM subtree. It compares this new tree with the previous Virtual DOM tree, calculates the minimal set of DOM operations required to reconcile the two, queues those changes, and batch-executes them against the real DOM in a single pass.
Pete Hunt explains the necessity of the abstraction: “We built a virtual DOM which makes re-rendering on every change really, really fast.”
```mermaid flowchart TD accTitle: React Virtual DOM Reconciliation Flow accDescr: Flowchart illustrating how state changes trigger render, Virtual DOM tree diffing, and batched real DOM mutations.
subgraph StateUpdate ["1. State & Render"] A["setState called"] --> B["Generate new Virtual DOM subtree"] end
subgraph Reconciliation ["2. Reconciliation"] B --> C["Diff new Virtual DOM against previous tree"] C --> D["Compute minimal set of DOM mutations"] end
subgraph BrowserExecution ["3. Browser Mutation"] D --> E["Queue operations"] E --> F["Batch flush to native browser DOM"] end ```
[23:51](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1431s) Comparing React to the Doom 3 Engine
To demystify how this architecture works under the hood, Pete compares React directly to modern game engine architecture, citing online write-ups detailing the design of the *Doom 3* engine. A 3D game engine continuously processes input without micro-managing individual pixel changes manually across frames.
In *Doom 3*, the front end ingests world state—user inputs and environmental variables—and runs game logic determining physics, movement, weapons, and open doors. This pipeline outputs a "scene intermediate representation," describing abstractly what exists in the world (such as an enemy positioned at specific XYZ coordinates with a door opened exactly 50 percent). The rendering engine back end consumes this intermediate representation, converts it into low-level OpenGL draw calls, and flushes them to the graphics hardware.
React mirrors this exact separation of concerns. Instead of game state and user controller inputs, React takes component state and browser events. Instead of game logic and 3D level scripts, developers write React components expressing business logic. These components render to an intermediate representation—the Virtual DOM. Finally, React’s reconciliation back end diffs that intermediate tree, calculates the minimal mutations, and flushes native DOM operations to the browser window rather than dispatching raw OpenGL commands to a GPU.
Pete Hunt highlights the parallel between the game engine pipeline and web UI: “Rather than game logic and 3D levels, we have your React components that you've described—that's the business logic of your application that renders to this virtual DOM.”
[25:31](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1531s) Layout Thrashing, Batching, and Synthetic Events
Pete dispels the notion that React relies on unexplainable magic, remarking that fundamentally slow algorithmic operations cannot be magically cured by a framework. He compares hand-tuning DOM updates to writing raw assembly language instead of relying on a C compiler: while hand-written assembly can theoretically beat a compiler, maintaining hand-optimized DOM mutations across large teams and massive codebases is nearly impossible.
The primary bottleneck in web applications is layout thrashing. When JavaScript modifies the DOM and immediately reads back layout geometry (such as measuring element heights or offsets), the browser is forced to halt execution and synchronously recalculate styles and geometry. Interleaving DOM reads and DOM writes causes severe cascading reflows. Because React completely mediates UI changes through an in-memory Virtual DOM, it schedules reads and writes globally, batching operations together so that DOM thrashing is structurally prevented.
Beyond layout batching, the Virtual DOM enables performance optimizations through React's synthetic event system: - **Automatic Event Delegation:** Instead of binding discrete listeners to every node in a massive data table, React binds a single event listener at the root container. - **In-Memory Dispatch:** Capture and bubble phases are reimplemented entirely inside JavaScript by inspecting event targets against the Virtual DOM. - **Cross-Browser Parity:** The custom implementation normalizes behavior across platforms, delivering full W3C-compliant HTML5 event handling even in legacy browsers like Internet Explorer 8 (IE8). - **Escape Hatches:** For rare performance bottlenecks, React offers lifecycle hooks (such as custom update methods) that allow developers to bypass reconciliation on static subtrees with a single line of code, often yielding tenfold speedups.
Discussing manual performance optimizations versus React's scheduling, Pete Hunt notes: “React operates only on a virtual DOM, it can manage those reads and writes for you, so it basically optimizes globally for your application all of your reads and writes and batches them together, and because of this, we usually beat manual DOM operations.”
[29:11](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1751s) 60 FPS Mobile Performance Demo
Pete stresses that Facebook evaluates UI performance strictly by the metric of dropped frames. Modern user experiences, especially on mobile devices where web traffic is expanding rapidly, must sustain a fluid 60 frames per second (FPS). If an abstraction cannot hit 60 FPS on mobile hardware, Pete asserts that it is not worth adopting.
To prove the efficiency of the Virtual DOM diff engine, he demonstrates an interactive mobile menu running smoothly at 60 FPS. Every frame must execute its full cycle in under 10 milliseconds to maintain that threshold:
- **Full Frame Re-rendering:** React computes a Virtual DOM diff, reconciles the changes, and flushes updates to the browser DOM on every single `requestAnimationFrame`. - **Zero CSS Shortcuts:** The demo deliberately avoids native CSS animations, CSS transitions, and native `overflow: scroll`. - **Physics via JavaScript:** The application integrates the Zynga Scroller library to capture raw touch events and calculate scroll positions in JavaScript. - **Complex Visuals:** Touch coordinates directly update React state, driving real-time 3D transforms alongside a simulated frosted-glass overlay effect that animates two layered content surfaces—one clear and one blurred—entirely via declarative code.
Affirming the team's commitment to high frame rates, Pete Hunt emphasizes: “At the end of the day, we really, really value performance, and we look at performance in terms of dropped frames; you can do all of this at 60 frames per second, even on a mobile device.”
[30:41](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1841s) Declarative Performance and Isomorphic JavaScript
Pete Hunt emphasizes that high performance should never require abandoning reactive data flow. While traditional frameworks often force developers to step outside their reactive or data-binding systems to squeeze out performance for demanding interactions, React is built to make that unnecessary. Declarative code remains maintainable and pleasant to write, and React strives to keep that style performant enough for real-world interactions.
Beyond client-side UI, running React on the server via Node.js opens up powerful possibilities—a concept increasingly known as "isomorphic JavaScript." Standard client-rendered applications face severe search engine optimization problems: when Googlebot crawls a page, it typically encounters a mostly empty HTML skeleton with a few script tags, leading to poor search ranking. Common workarounds involve detecting the crawler and rendering through headless browsers like PhantomJS, but this approach is computationally prohibitive at scale because spinning up a full DOM environment for every crawl request is expensive.
React sidesteps this penalty while simultaneously improving the experience for human users. By executing component logic in Node.js, React can spit out a static HTML string directly to the client. The browser displays this markup immediately, giving the user instant visual content. When the client-side JavaScript finishes downloading and executing, React inspects the existing DOM markup:
> “I don't need to generate any Dom nodes I just need to attach my event listeners and get started so you get a really fast initial page page load experience which is great”
```mermaid flowchart TD accTitle: Isomorphic Rendering Flow in React accDescr: Diagram showing how React renders static HTML on the server and attaches event listeners on the client without recreating DOM nodes.
subgraph Server["Server (Node.js)"] A["React Component"] -->|"renderToString()"| B["Static HTML Document"] end
subgraph Client["Client Browser"] B -->|"Fast Initial Load"| C["Rendered DOM"] D["React Client JS Bundle"] -->|"renderComponent()"| E{"Examine Existing Markup"} C -.-> E E -->|"Match found: Hydrate & attach listeners"| F["Fully Interactive App"] end ```
[32:44](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1964s) Alternative Targets: Canvas, Web Workers, and Painless Testing
Because React compiles components to an abstract virtual DOM rather than manipulating the browser DOM directly, it gains architectural leverage that traditional template engines cannot match:
- **Subtree Optimization on Navigation:** Because React understands the high-level semantic language of an application, switching major views (for instance, navigating from News Feed to a user Profile) allows React to recognize that a top-level component type changed and apply an optimized batch-clearing strategy to swap large subtrees. - **Painless Unit Testing:** Components are completely decoupled from browser APIs. Developers do not need to orchestrate heavy headless browser suites like Selenium or WebDriver just to test business logic; they can simply execute a component in a test runner, render it to a string with given properties, and run standard string or data assertions. - **Rendering to Non-DOM Targets:** Pete highlights work done by his colleague Sebastian Markbåge, who built SVG, VML, and HTML5 Canvas support for React. Instead of targeting browser DOM primitives, an alternate virtual DOM implementation targets canvas drawing contexts, enabling teams to build interactive graphics, charts, and data visualizations using the exact same declarative component paradigm used for typical web UI. - **Off-Thread UI Execution via Web Workers:** Pete describes an experimental branch of React—implemented in roughly 100 lines of code—that runs an entire application inside a Web Worker. By serializing native browser events from the main UI thread into the worker and piping back an abstracted description of DOM mutations, the heavy computation of view logic is offloaded from the UI thread, potentially unlocking stutter-free interactions.
[35:17](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=2117s) Summary and the Announcement of React Chrome Developer Tools
Pete summarizes the core philosophy of React down to three foundational pillars: 1. **Build components, not templates.** 2. **Render, don't mutate.** 3. **The virtual DOM is simple and fast.**
Following the original announcement open-sourcing React at JSConf US earlier that year, Pete reveals a new release for the JSConf.Asia audience: the React Chrome Developer Tools extension. While the standard Chrome DevTools Elements panel displays raw, noisy, deeply nested HTML markup that obscures application intent, the React tab exposes the actual component tree—displaying semantic structures like `ImageBlockLayout` or `Story`.
Developers can inspect properties directly in the sidebar. For instance, toggling a component prop like `viewerHasLiked` from `false` to `true` immediately updates the live UI by displaying the filled heart icon and appending the user's name to the list of likes, demonstrating how React's declarative state guarantees that the interface remains synchronized.
> “React guarantees that your app is consistent”
[37:04](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=2224s) Q&A: Web Components, Transitions, jQuery Integration, and Mobile
The presentation concludes with audience questions on architecture, ecosystem compatibility, and Facebook's roadmaps:
- **React vs. Web Components:** When asked how React compares to the emerging Web Components specification, Pete notes that Web Components encompasses several changing standards (such as Shadow DOM, which React could potentially utilize), but historically lacked deep focus on composability and nuanced parent-child data flow. He highlights a core philosophical contrast: > “Web components fully embraces the Dom and adds new apis react kind of hates the Dom and puts it away in its own little corner and um we only interact with it um through message passing basically” By insulating itself from the DOM, React can easily render server-side for fast, non-blocking page loads, a problem that Web Components had not yet solved. - **Handling UI Transitions:** In response to a question about CSS and render transitions, Pete mentions `ReactTransitionGroup`. Modeled similarly to AngularJS's `ngAnimate`, it monitors when children enter or leave a list, automatically managing transition CSS classes to make fade-ins, slide-ins, or custom JavaScript DOM transition states simple. - **Interoperability with Legacy Code and jQuery Plugins:** When asked whether an external script (such as a jQuery plugin) modifying class names on a React-managed DOM node causes conflicts, Pete explains that React was built from the start to integrate with legacy software. React provides Objective-C/Cocoa-inspired lifecycle hooks: - `componentDidMount`: Fires when the element is placed into the page and the raw DOM node exists; this is where developers instantiate jQuery plugins. - `componentDidUpdate`: Fires after props or state change, allowing developers to notify the jQuery plugin of updated data. - `componentWillUnmount`: Fires right before removal, providing a hook to cleanly teardown and destroy the plugin instance. - **Facebook Mobile and Instagram:** Asked whether React's mobile rendering performance hints at a revamp of Facebook's hybrid mobile applications, Pete clarifies that he does not work on the Facebook mobile site team and cannot speak to their roadmap, though he notes React is already deployed heavily across all web properties on instagram.com.
## Notable quotes > [05:18](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=318s) So what we're actually doing when we're using templates and display logic and separating those out, we're separating technologies, not concerns. — Pete Hunt
> [16:55](https://www.youtube.com/watch?v=DgVS-zXgMTk&t=1015s) React components are just idempotent functions that describe your UI at any point in time, just like a server-rendered app. — Pete Hunt
## Mentioned Pete Hunt, Edsger W. Dijkstra, Sebastian Markbåge, React, Facebook, Instagram, Handlebars, AngularJS, JSX, Doom 3, Node.js, Zynga Scroller, PhantomJS, Web Components, React Chrome Developer Tools, jQuery
## Video description Announcement of the React Chrome Developer Tools http://facebook.github.io/react/blog/2014/01/02/react-chrome-developer-tools.html
"React, the new open-source JS library from Facebook and Instagram, is a different way to write JavaScript apps. When it was introduced at JSConf US in May, the audience was shocked by some of its design principles. One sarcastic tweet from an audience member ended up describing React's philosophy quite accurately: https://twitter.com/cowboy/status/339858717451362304 At Facebook and Instagram, we're trying to push the limits of what's possible on the web with React. My talk will start with a brief introduction to the framework, and then dive into three controversial topics: Throwing out the notion of templates and building views with JavaScript, 're-rendering' your entire application when your data changes, and a lightweight implementation of the DOM and events."
Pete is a member of the React core team at Facebook and also the sole engineer on Instagram.com. He has also designed and implemented the video encode backend infrastructure for Facebook and Instagram and computer vision infrastructure and general front-end web engineering for Facebook photos. Pete likes to play guitar and rock climbing when he is not hacking.
JSConf.Asia is the JavaScript, web and mobile developer conference for Asia. Hotel H2O and Manila Ocean Park, Philippines - 28 + 29 November 2013.
Source: http://2013.jsconf.asia/blog/2013/10/31/jsconfasia-2013-pete-hunt-react-rethinking-best-practices Slides: http://www.slideshare.net/floydophone/react-preso-v2
License: For reuse of this video under a more permissive license please get in touch with us. The speakers retain the copyright for their performances.
[Source](https://www.youtube.com/watch?v=DgVS-zXgMTk)