Skip to content

White background, black text

How Web Browsers Interpret the Stack, then JavaScript and Its Flavors

This page explains how browsers render HTML, CSS, and JavaScript, then introduces JavaScript and several modern frameworks. Examples are minimal and practical.

Open the Responsive Demo

How Browsers Interpret HTML, CSS, and JavaScript

Browsers parse HTML into a DOM, CSS into a CSSOM, and merge them into a render tree. The layout is calculated and then painted as pixels. JavaScript can modify this structure dynamically.

HTML Parsing → DOM

The HTML stream is tokenized into elements and attributes. The DOM tree is built to represent the document’s structure and content.

CSS Parsing → CSSOM

CSS rules are parsed into an object model. Cascading rules, inheritance, and specificity determine the final style applied to each element.

Render Tree, Layout, and Paint

The render tree combines the DOM and CSSOM. Layout determines the position and size of each node, then the browser paints pixels to the screen.

JavaScript Execution

Browsers implement the ECMAScript standard, exposing APIs that allow scripts to manipulate the DOM, handle events, and perform network operations.

JavaScript Overview

JavaScript is standardized as ECMAScript. It runs in browsers and other environments like Node.js, providing both language syntax and access to APIs.

Language vs. Platform

  • ECMAScript: Defines syntax, types, and core language features.
  • Web APIs: Expose the DOM, Fetch, Storage, and Workers.

Modules

Use ES modules with <script type="module"> and the import/export syntax to structure code and manage dependencies.

Common Patterns

  • Progressive enhancement for static content.
  • Component-based design for complex UIs.
  • TypeScript for large-scale maintainability.

Minimal Example

<button id="hi">Say Hello</button>
<script type="module">
  document.getElementById('hi').addEventListener('click', () => {
    alert('Hello from ES Modules');
  });
</script>

Common JavaScript “Flavors” and Frameworks

Modern frameworks build upon JavaScript to improve structure, performance, or maintainability.

TypeScript

TypeScript

Adds static typing to JavaScript. Compiles to standard JavaScript for runtime execution.

function greet(name: string): string {
  return `Hello, ${name}`;
}
console.log(greet("Ada"));
React (JSX)

React + JSX

JSX is a syntax extension that compiles to function calls returning virtual DOM elements.

export default function App() {
  return <button onClick={() => alert('Hi')}>Click</button>;
}
Vue

Vue

A framework emphasizing reactivity and templates.

<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>

<template>
  <button @click="count++">Clicked {{ count }}</button>
</template>
Svelte

Svelte

A compiler that turns declarative components into efficient vanilla JavaScript code.

<script> let n = 0; </script>
<button on:click={() => n++}>Clicked {n}</button>
Angular

Angular

A full-featured framework using TypeScript, templates, and dependency injection for enterprise-grade applications.

import { Component } from '@angular/core';
@Component({
  selector: 'hello',
  template: `<button (click)="onClick()">Click</button>`
})
export class HelloComponent {
  onClick() { alert('Hi'); }
}

Tooling and Modules

Modules and Bundling

  • ES Modules: Supported natively in browsers.
  • Bundlers: Tools like Vite, esbuild, and Webpack optimize code.
  • Transpilers: Convert modern syntax (TypeScript, JSX) into supported JavaScript.

Choosing an Approach

  • Simple static sites: vanilla JavaScript.
  • Interactive interfaces: React or Vue.
  • Large projects: TypeScript with Angular or React.
  • Performance-critical: Svelte or lighter alternatives.

Performance Practices

  • Load critical CSS first; defer nonessential scripts.
  • Batch DOM reads and writes to avoid reflows.
  • Use browser dev tools to measure rendering and optimize hot paths.

Sources Used (APA)

  1. Ecma International. (2025). ECMAScript 2025 language specification (ECMA-262, 16th ed.). https://262.ecma-international.org/
  2. Mozilla. (2025). Critical rendering path. MDN Web Docs. https://developer.mozilla.org/
  3. WHATWG. (n.d.). HTML Living Standard. https://html.spec.whatwg.org/
  4. W3C. (2024). CSS Cascading and Inheritance Levels 3–6. https://www.w3.org/TR/
  5. Meta Open Source. (n.d.). Introducing JSX. React documentation. https://react.dev/
  6. TypeScript Team. (n.d.). The TypeScript Handbook. https://www.typescriptlang.org/
  7. Vue Core Team. (n.d.). Introduction. https://vuejs.org/
  8. Svelte Core Team. (n.d.). Documentation and Tutorial. https://svelte.dev/