Frontend

On this page 7

The frontend is the part of a web application that runs on the user’s device, usually in the browser, and is responsible for everything a person sees and interacts with: page structure, layout, visual design, input handling and the logic that turns data into an interface. In web architecture, it is the presentation layer that sits opposite the backend, communicating with servers through HTTP requests and APIs.

Frontend code is built from three core technologies: HTML for structure, CSS for presentation and JavaScript for behavior. Around them sits a large toolchain of frameworks, bundlers and testing tools, but the defining feature stays the same: frontend code executes in an environment the developer does not control, on unknown hardware, screen sizes, network speeds and browser versions.

What the frontend layer is responsible for

The frontend translates data and business rules provided by the backend into a usable, accessible and fast interface. Its responsibilities go well beyond appearance, because the browser is also where user input is first collected, where state changes are reflected and where most perceived performance is decided.

The following table breaks the layer into its main areas of responsibility.

ResponsibilityTypical technologyWhat it covers
Structure and semanticsHTMLDocument outline, landmarks, forms, meaning for assistive technology
Presentation and layoutCSS, design tokensTypography, grid and flexbox layout, responsive breakpoints, themes
Interaction and stateJavaScript, TypeScriptEvent handling, client state, routing, form validation
Data accessfetch, GraphQL clientsCalling APIs, caching responses, handling loading and errors
PerformanceBundlers, image formatsCode splitting, lazy loading, Core Web Vitals
AccessibilityARIA, semantic HTMLKeyboard access, focus order, screen reader support
Core responsibilities of the frontend

A crucial boundary applies to all of these: validation and security checks in the frontend are a convenience, not a safeguard. Anything running in the browser can be inspected and modified by the user, so the backend must enforce every rule again.

How the frontend renders a page

Every frontend ultimately feeds the browser’s rendering pipeline: the browser parses HTML into the DOM, parses CSS into the CSSOM, combines them into a render tree, calculates layout, paints pixels and composites layers. JavaScript can change the DOM at any point, which is powerful but also the most common source of layout thrashing and slow interactions.

Where the HTML is produced is the key architectural decision. The table compares the main rendering strategies used by modern frontends.

StrategyWhere HTML is builtStrengthsWeaknesses
Client-side rendering (CSR)In the browser at runtimeRich interactivity, simple hostingSlow first paint, weaker for crawlers
Server-side rendering (SSR)On the server per requestFast first content, good for SEOServer cost, hydration overhead
Static site generation (SSG)At build timeVery fast, cheap CDN deliveryRebuilds needed for content changes
Incremental regenerationAt build time, refreshed laterStatic speed with fresher dataCache invalidation complexity
Islands and partial hydrationServer, with isolated client partsShips little JavaScriptMore complex component boundaries
Frontend rendering strategies

Most production sites combine strategies, for example static marketing pages with a client-rendered dashboard behind login. The choice depends on how dynamic the content is, how important search visibility is and how much JavaScript the target devices can execute quickly.

Frontend compared with backend and full stack

The frontend and backend divide a web application by where code runs and whom it trusts. Neighboring terms in web architecture, such as Backend, Full Stack and Headless Architecture, describe the other side of that line or ways of connecting the two.

AspectFrontendBackendFull stack
Execution environmentBrowser or client deviceServers and cloud servicesBoth
Trust levelUntrusted, user-controlledTrusted, operator-controlledMust respect both boundaries
Main concernsInterface, interaction, perceived speedData, business rules, securityEnd-to-end features
Typical languagesHTML, CSS, JavaScript, TypeScriptJava, Go, Python, PHP, Node.jsA mix of both sides
Key metricsLCP, INP, CLS, accessibilityLatency, throughput, error rateFeature delivery speed
Frontend versus related architectural roles

In a headless architecture, the frontend is fully decoupled from a content or commerce backend and consumes it only through APIs. This gives frontend teams freedom over frameworks and release cycles, at the cost of more integration work and responsibility for rendering, caching and SEO.

The modern frontend toolchain

Source code written by developers is rarely what the browser receives. A build step transforms it: TypeScript is compiled, modules are bundled, unused code is removed by tree shaking, assets are minified and fingerprinted for long-term caching, and images are converted to efficient formats such as WebP or AVIF.

  • Component frameworks such as React, Vue, Angular and Svelte organize the interface into reusable pieces with their own state.
  • Bundlers and build tools such as Vite, webpack and esbuild resolve imports and produce optimized output files.
  • Styling approaches range from plain CSS with custom properties to CSS modules and utility-first frameworks.
  • Testing layers include unit tests, component tests, end-to-end browser tests and visual regression checks.
  • Design systems keep components, tokens and accessibility patterns consistent across teams and products.

Common frontend pitfalls

Most frontend problems come from shipping too much code or from treating the developer’s fast laptop as representative. A median mobile device parses and executes JavaScript several times more slowly than a modern desktop, so a bundle that feels instant in the office can make a page unresponsive for seconds on a mid-range phone.

MistakeConsequenceBetter practice
Oversized JavaScript bundlesSlow startup, poor INPCode splitting and a performance budget
Div-only markupInaccessible to screen readersSemantic HTML elements first
Unsized images and embedsLayout shifts, poor CLSExplicit width, height or aspect ratio
Trusting client validationSecurity holesRepeat every check on the server
Testing on one browserBroken layouts for some usersCross-browser and device testing
Frequent frontend mistakes

The most reliable defense is measuring with real-user data and treating accessibility and performance as requirements from the first sprint rather than fixes before launch.

In plain words

Think of a restaurant. The dining room is the frontend: the menu, the tables, the lighting and the waiter who takes your order. The kitchen is the backend, where food is actually prepared and stored.

On a website, the frontend is everything you see and click in your browser: buttons, text, images and forms. It collects what you want, passes the request to the server and then presents the answer in a clear and pleasant way.

A real-world example

An online furniture retailer finds that most visitors arrive on phones, yet product pages take more than five seconds to become interactive on mid-range devices. An audit shows a single 1.2 MB JavaScript bundle that loads the checkout, reviews widget and 3D viewer on every page.

The frontend team switches product pages to server-side rendering, splits the bundle so the 3D viewer loads only when a shopper taps it, sets explicit dimensions on product photos and serves them as AVIF. They also replace clickable div elements with real buttons so keyboard and screen reader users can add items to the cart.

After the release, product pages show their main image in about two seconds on the same phones, layout shifts largely disappear and the mobile conversion rate rises noticeably. No backend code changed; the gains came entirely from the frontend.