Diploma in Full Stack Programming
Frontend Development using React.js or Angular
•
Diploma
Modern Web and Frontend Foundations
Introduction
Frontend development is the discipline of designing and implementing the part of a digital product that users see and interact with. It includes visual presentation, navigation, forms, accessibility, performance, state management, and communication with backend services. React.js and Angular are important frontend technologies, but effective use of either framework depends on understanding the web platform beneath them.
The modern web is a distributed information system. A user interacts with a browser running on a device; the browser communicates through networks with web servers, application servers, databases, identity providers, content-delivery networks, and third-party services. Frontend developers therefore need more than knowledge of components and syntax. They must understand how a URL is resolved, how an HTTP request is processed, how HTML becomes a rendered page, how JavaScript changes the DOM, and how application architecture affects security, accessibility, maintainability, and business outcomes.
This chapter establishes those foundations.
Learning Objectives
By the end of this chapter, you should be able to:
describe the principal components of browser architecture;
explain client-server communication and the request-response model;
interpret URLs, DNS resolution, HTTP methods, status codes, headers, and HTTPS;
distinguish HTML parsing, CSS calculation, layout, painting, and compositing;
explain the DOM and how JavaScript interacts with it;
distinguish web APIs from application programming interfaces exposed by a backend;
compare traditional multi-page applications with single-page applications;
explain progressive enhancement and its relationship to accessibility and resilience;
identify the professional role of frontend development in digital transformation.
1. The Web as a Distributed Platform
The World Wide Web is built on open standards. A browser requests resources identified by URLs, and servers return representations such as HTML documents, stylesheets, scripts, images, video, or structured data. The browser then interprets those resources and presents an interactive interface.
A typical interaction involves several layers:
User interface layer: controls, text, images, forms, and feedback visible to the user.
Browser platform layer: HTML, CSS, JavaScript, the DOM, browser APIs, storage, networking, and security controls.
Network layer: DNS, TCP or QUIC, TLS, routing, proxies, and content-delivery networks.
Application layer: web servers, backend services, authentication systems, business rules, and databases.
The browser is not merely a document viewer. It is a secure runtime environment that executes code supplied by many parties while restricting that code from harming the user's device or accessing unrelated data.
2. Browser Architecture
Although implementation details differ among browsers, a useful conceptual model includes the following components.
2.1 User interface
The browser's user interface contains the address bar, tabs, navigation buttons, menus, download controls, and permission prompts. This interface is distinct from the web page itself, although both may appear within the same window.
2.2 Browser process and renderer processes
Modern browsers commonly separate responsibilities into processes. A browser or “browser” process may coordinate tabs, navigation, permissions, and operating-system integration. A renderer process may parse HTML, calculate styles, execute JavaScript, and paint a page. Network and graphics work may be handled by specialised processes or services.
Process isolation improves stability and security. If one page crashes, the entire browser need not fail. Site isolation can also reduce the ability of a compromised page to access memory associated with another site. Process boundaries are implementation strategies rather than guarantees that every browser uses exactly the same architecture.
2.3 Rendering engine
The rendering engine converts web resources into pixels. Its broad tasks are:
parse HTML into a document structure;
parse CSS into style rules;
combine structure and style information;
calculate geometry through layout;
draw backgrounds, text, borders, and images through painting;
combine layers through compositing;
display the result through the graphics system.
A simplified rendering pipeline is shown below.
Browser rendering pipeline from resources to displayed pixels
Figure: Browser rendering pipeline from resources to displayed pixels
Figure: A simplified browser rendering pipeline. Actual implementations may overlap or repeat stages.
2.4 JavaScript engine
The JavaScript engine parses and executes JavaScript. It may interpret code initially and compile frequently executed sections for improved performance. JavaScript execution is coordinated with browser tasks such as input, timers, network callbacks, and rendering. The event loop helps organise these tasks, but long-running JavaScript can delay interaction and visual updates.
2.5 Browser security boundary
A page executes within an origin. An origin is generally defined by a scheme, host, and port. The same-origin policy restricts scripts from freely reading data belonging to another origin. Cross-Origin Resource Sharing (CORS) provides a controlled mechanism for servers to permit selected cross-origin requests. Other important controls include Content Security Policy, cookie attributes, permissions, sandboxing, and mixed-content blocking.
Security restrictions are not obstacles to be bypassed casually. They protect users from attacks such as credential theft, cross-site scripting, cross-site request forgery, and unauthorised data access.
3. URLs, DNS, and Network Communication
3.1 Anatomy of a URL
A URL identifies the location and access method of a resource. For example:
Identifies a location within the returned document
A fragment is normally processed by the browser and is not sent to the server in the HTTP request. Query parameters, in contrast, are sent as part of the request target and should not contain secrets unless their exposure is acceptable.
3.2 DNS resolution
Humans use domain names, while network communication ultimately uses IP addresses. The Domain Name System (DNS) maps names to records such as IPv4 addresses, IPv6 addresses, mail servers, and aliases. A resolver may consult cached information, a recursive resolver, root servers, top-level-domain servers, and authoritative name servers. Caching reduces delay and traffic, but it means that changes may not be visible immediately.
DNS does not itself encrypt ordinary name resolution. DNS over HTTPS and DNS over TLS are approaches that can protect the resolver communication, although they do not make all browsing activity anonymous.
3.3 The request-response model
A browser usually sends a request containing a method, target, headers, and sometimes a body. A server returns a response containing a status code, headers, and optionally a body.
For example, a browser might send a GET request for a stylesheet. The server may return status 200, a content type of text/css, caching instructions, and the stylesheet bytes. The browser can then parse the stylesheet and apply its rules.
The request-response model is stateless at the protocol level: each HTTP request is independent. Applications create continuity using cookies, tokens, server-side sessions, URLs, or client-side state.
4. HTTP and HTTPS
HTTP is an application-layer protocol for transferring representations and messages. It defines methods, status codes, headers, caching semantics, and rules for message exchange.
4.1 Common HTTP methods
GET: requests a representation; it should not intentionally change server state.
POST: submits data, often requesting creation or an action.
PUT: replaces or creates a representation at a known target, when the application defines that meaning.
PATCH: applies a partial modification.
DELETE: requests removal of a resource.
HEAD: requests headers without the response body.
OPTIONS: asks about communication options, commonly used in CORS preflight operations.
The distinction between safe and idempotent methods matters. A safe method is intended to be read-only from the user's perspective. An idempotent operation has the same intended effect when repeated, although responses and logging may differ. PUT and DELETE are generally designed to be idempotent; POST is generally not.
4.2 Status codes
Class
Meaning
Examples
1xx
Informational
101 Switching Protocols
2xx
Successful
200 OK, 201 Created, 204 No Content
3xx
Redirection or caching action
301 Moved Permanently, 304 Not Modified
4xx
Client-side request problem
400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found
5xx
Server-side failure
500 Internal Server Error, 503 Service Unavailable
A 401 response normally indicates that authentication is required or has failed, whereas 403 indicates that the server understood the request but refuses to authorise it. Applications should not expose unnecessary internal details in error responses.
4.3 Headers, caching, and cookies
Headers carry metadata and instructions. Content-Type describes the representation format; Accept communicates preferred formats; Cache-Control controls caching; Authorization carries credentials or tokens according to the chosen scheme; and Set-Cookie asks the browser to store a cookie.
Caching improves performance and reduces server load, but stale or incorrectly shared data can create functional and security problems. Private user responses should not be stored in a shared cache unless the policy is carefully designed.
Cookies can be configured with Secure, HttpOnly, SameSite, an expiration policy, and a restricted path or domain. HttpOnly prevents ordinary JavaScript access, reducing some theft risks, while SameSite can reduce cross-site request forgery. These attributes do not replace sound authentication and authorisation design.
4.4 HTTPS and TLS
HTTPS is HTTP carried through Transport Layer Security (TLS). TLS provides encryption in transit, integrity protection, and server authentication based on certificates and a trusted certificate system. HTTPS protects data while travelling between endpoints, but it does not make an insecure application secure. Vulnerable server logic, malicious scripts, weak passwords, and poor access control remain risks.
Developers should avoid mixed content, use secure cookies, redirect HTTP to HTTPS where appropriate, and never treat client-side validation as a substitute for server-side validation.
5. From HTML to the DOM
HTML is a markup language that describes document structure and meaning. Elements such as header, nav, main, button, form, and article provide semantic information. Semantic HTML supports accessibility technologies, search engines, maintainability, and keyboard interaction.
When the browser parses HTML, it creates a Document Object Model (DOM): an in-memory tree of nodes. Elements, attributes, text, and document relationships can be represented as nodes. JavaScript can query and modify this tree using APIs such as querySelector, classList, setAttribute, and event listeners.
The DOM is not identical to the HTML source. JavaScript can change it after parsing, and the browser may insert implied elements or correct certain markup errors. The DOM is also distinct from a framework's virtual representation. React commonly maintains a virtual representation and commits selected changes to the real DOM; Angular uses templates, bindings, and its own change-detection mechanisms. In both cases, the final user-visible output depends on browser platform behaviour.
5.1 Events and interaction
An event represents something that occurs, such as a click, keyboard input, pointer movement, form submission, or network completion. Events generally travel through capturing, target, and bubbling phases. Event delegation can attach one listener to a stable ancestor rather than many individual descendants.
Accessible interaction requires more than responding to mouse clicks. Controls should support keyboard operation, have meaningful names, provide visible focus, and communicate state changes to assistive technologies. A native button is usually preferable to a div with a click listener because the browser already supplies semantics and keyboard behaviour.
6. Web APIs and Application APIs
A web API is a programming interface supplied by the browser. Examples include:
Fetch API for network requests;
DOM APIs for document manipulation;
Web Storage for limited key-value storage;
History API for changing URL state without a full navigation;
WebSocket API for persistent bidirectional communication;
Geolocation API, subject to permission;
Web Workers for some background computation;
Service Workers for controlled caching and offline-related behaviour.
An application or backend API is an interface exposed by a software system. It may provide endpoints such as GET /api/products/42, accept JSON, require authentication, and enforce business rules. The browser's Fetch API may call that backend API, but the two concepts are not interchangeable.
A robust frontend treats remote data as uncertain. Requests can fail, be slow, return incomplete data, or be rejected because the user is unauthorised. Interfaces should represent loading, success, empty, validation-error, authentication-error, and general-failure states. The server must validate all security-sensitive inputs because client code can be modified or bypassed.
7. Rendering, Performance, and Responsive Design
The browser's rendering work affects perceived quality. Changing layout-related properties may require new layout calculations; changing visual properties may require painting; some changes can be handled mainly through compositing. The exact cost depends on the browser, device, document, and property involved, so developers should measure rather than rely on simplistic rules.
Important performance practices include:
send only necessary JavaScript and CSS;
compress and appropriately size images;
lazy-load noncritical resources;
avoid blocking the main thread with long tasks;
reserve space for media to reduce layout shifts;
use caching and content delivery appropriately;
measure real-user performance as well as laboratory performance.
Responsive design uses flexible layouts, relative sizing, media queries, and content-aware breakpoints. It should not mean merely shrinking a desktop page. Touch targets, readable text, orientation, network conditions, and assistive technologies must be considered.
8. Multi-Page Applications and Single-Page Applications
In a traditional multi-page application (MPA), navigation commonly requests a new HTML document from the server. The browser replaces the current document and loads its resources. MPAs can provide strong initial delivery, simple URL semantics, and good resilience.
In a single-page application (SPA), the browser initially loads an application shell and JavaScript. Client-side routing changes the displayed view without necessarily requesting a complete new document. Data is then fetched from APIs, and the frontend updates the interface.
Concern
MPA
SPA
Navigation
Often full document request
Often client-side route transition
Initial JavaScript
Usually lower
Often higher
Rich interaction
Possible, sometimes page-based
Convenient for application-like interfaces
SEO and initial content
Often straightforward
Requires deliberate rendering strategy
Offline behaviour
Usually limited
Can be extended with service workers
Complexity
Distributed across server and pages
More client-side state and tooling
SPA is an architectural style, not a synonym for React or Angular. React and Angular can support SPA designs, but they can also participate in server-side rendering, static generation, or hybrid applications. A suitable architecture depends on content, interaction, device constraints, team capability, and operational requirements.
Rendering strategies
Client-side rendering: the browser constructs much of the interface using JavaScript.
Server-side rendering: the server generates HTML for a request, after which the client may “hydrate” it with interactivity.
Static generation: HTML is generated ahead of time and served from static infrastructure.
Hybrid rendering: different routes use different strategies.
No strategy is universally best. Client-side rendering can support rich applications but may delay meaningful content on slow devices. Server-side rendering can improve initial content delivery but adds server complexity and hydration concerns.
9. Progressive Enhancement
Progressive enhancement begins with a usable, accessible core and adds advanced capabilities when the browser and network support them. A form may submit through ordinary HTTP first; JavaScript can then enhance it with inline validation, asynchronous submission, and richer feedback.
Its related principle, graceful degradation, begins with a highly capable experience and attempts to make it function in less capable environments. Progressive enhancement is often more resilient because it treats the enhanced layer as an addition rather than the sole foundation.
Progressive enhancement does not require avoiding modern frameworks. A framework application can still provide semantic HTML, meaningful URLs, server validation, accessible controls, and useful behaviour when scripts fail or resources are delayed.
10. Frontend Development and Digital Transformation
Digital transformation is not simply the replacement of paper with websites. It involves redesigning processes, services, decisions, and relationships through digital capabilities. Frontend development is the point at which many of these capabilities become visible and usable.
Frontend professionals contribute by:
turning organisational processes into understandable workflows;
reducing friction in customer and employee journeys;
making services accessible across devices and abilities;
presenting data clearly for informed decisions;
integrating identity, payments, search, communication, and automation;
collecting responsible feedback and behavioural evidence;
creating consistent design systems that scale across products.
A technically impressive interface can still fail if it excludes users, obscures costs, creates confusing consent choices, or performs poorly on ordinary devices. Professional frontend development therefore joins engineering quality with user research, design, content, security, privacy, and measurable business outcomes.
Ethical and governance considerations
Frontend teams influence what users notice, understand, and choose. Ethical practice includes:
obtaining meaningful consent rather than relying on deceptive interfaces;
minimising personal data collection;
explaining automated decisions where appropriate;
avoiding discriminatory assumptions in forms and workflows;
protecting credentials and sensitive information;
ensuring keyboard, screen-reader, colour, language, and cognitive accessibility;
retaining auditability for important transactions.
Accessibility standards such as the Web Content Accessibility Guidelines provide a recognised basis for evaluation, but compliance should be treated as a minimum responsibility rather than the entire goal.
11. Illustrative Case: A Public Library Service Portal
Background
A regional library operates separate pages for searching books, renewing loans, registering for events, and contacting branches. Users report that the site is difficult to use on phones and that renewal failures are unclear.
Problem
The library wants a unified portal. It has limited development staff, must protect member information, and serves users with varied devices, languages, and accessibility needs.
Analysis
A pure SPA could provide smooth transitions, but a large initial bundle would disadvantage users on slow connections. A fully separate MPA could be simpler but would duplicate interface patterns. The team identifies public catalogue pages, member-only actions, and staff workflows as different needs.
Approach
The team chooses a hybrid architecture. Public catalogue and event information are server-rendered or statically generated for fast discovery. Member actions use authenticated API requests. A design system supplies accessible buttons, form controls, alerts, and loading states. URLs remain meaningful, and the History API supports client-side transitions where appropriate. Server-side validation remains authoritative.
The team tests:
keyboard navigation and screen-reader announcements;
behaviour with JavaScript disabled or delayed;
slow-network loading;
expired sessions and failed API calls;
protection of cookies and personal data;
small-screen layouts;
clear messages for unavailable books and renewal restrictions.
Outcome
The resulting service gives users fast access to public information while retaining rich interaction for authenticated tasks. Failures are communicated in plain language, and the team can measure search completion, renewal success, error rates, and performance across devices.
Learning points
Architecture should follow user and organisational needs, not framework fashion.
A frontend must represent failure and uncertainty, not only the success path.
Progressive enhancement and server validation improve resilience.
Performance and accessibility are product qualities, not optional polish.
A design system reduces inconsistency and supports organisational scale.
12. Best Practices for Diploma-Level Frontend Work
Use semantic HTML before adding custom behaviour.
Keep URLs meaningful, stable, and shareable.
Treat every network request as fallible.
Separate presentation, state, and data-access responsibilities.
Validate and authorise on the server as well as providing client feedback.
Use HTTPS and secure cookie settings in production.
Test keyboard use, responsive layouts, slow networks, and screen readers.
Measure performance with browser developer tools and real-user data.
Avoid unnecessary dependencies and excessive JavaScript.
Document assumptions, API contracts, error states, and security decisions.
Use React or Angular to solve application problems rather than to replace knowledge of HTML, CSS, JavaScript, and HTTP.
Chapter Summary
The web is a distributed platform in which browsers retrieve and transform network resources into interactive interfaces. Browser architecture includes user-interface services, rendering engines, JavaScript execution, networking, graphics, and security boundaries. URLs identify resources; DNS maps domain names to network destinations; HTTP defines requests, responses, methods, headers, status codes, caching, and cookies; and HTTPS adds TLS-based confidentiality, integrity, and server authentication.
HTML is parsed into the DOM, CSS determines presentation, and the browser performs style calculation, layout, painting, and compositing. JavaScript uses DOM and browser APIs to respond to events and communicate with backend APIs. MPAs and SPAs offer different trade-offs, while server-side rendering, client-side rendering, static generation, and hybrid approaches provide additional choices. Progressive enhancement improves resilience by establishing a useful core before adding advanced capabilities.
Frontend development contributes directly to digital transformation by making services usable, accessible, secure, measurable, and responsive to organisational goals. React and Angular are valuable tools, but professional results depend on platform knowledge, architectural judgement, testing, ethical design, and attention to real users.
Key Terms
Browser: Software that retrieves, interprets, and displays web resources.
Client: A device or program that requests services from another system.
Server: A system that provides resources or services to clients.
URL: A Uniform Resource Locator identifying a resource and access method.
DNS: The Domain Name System, which maps names to network records.
HTTP: The Hypertext Transfer Protocol used for web message exchange.
HTTPS: HTTP protected by Transport Layer Security.
TLS: A protocol providing encrypted, integrity-protected communication and authentication.
DOM: The Document Object Model representing a document as an in-memory tree.
Rendering engine: Browser subsystem that transforms resources into displayed output.
Event loop: A mechanism coordinating JavaScript tasks and asynchronous callbacks.
Web API: An interface supplied by the browser platform.
Backend API: An application interface exposing server-side data or operations.
CORS: A controlled browser mechanism for permitted cross-origin requests.
SPA: A single-page application that updates views without routinely loading complete documents.
MPA: A multi-page application in which navigation commonly loads new documents.
Progressive enhancement: Building a useful core and adding capabilities when supported.
Accessibility: Designing technology so people with varied abilities can use it.
Origin: The combination of scheme, host, and port used in browser security decisions.
Hydration: Attaching client-side behaviour to server-generated HTML.
Review Questions
Short Answer Questions
What are the main stages in the browser rendering pipeline?
Why is DNS required when a user enters a domain name?
Distinguish the purposes of the 401 and 403 HTTP status codes.
What is the DOM, and how can JavaScript interact with it?
Define progressive enhancement.
Long Answer Questions
Explain the conceptual architecture of a modern browser and discuss why process isolation is valuable.
Describe a complete journey from entering an HTTPS URL to seeing a rendered page.
Compare MPAs and SPAs, including their performance, accessibility, SEO, and maintenance trade-offs.
Explain how HTTP methods, headers, cookies, caching, and status codes support application design.
Discuss the contribution of frontend development to digital transformation, including ethical and governance responsibilities.
Analytical / Application Questions
A mobile banking interface loads quickly on desktop but is unusable on a slow mobile connection. Analyse likely causes and propose a measurement-based improvement plan.
A frontend calls a backend API from a different origin and receives a CORS error. Explain the browser's security reason and identify a secure server-side approach to permitting the required request.
Design a rendering and progressive-enhancement strategy for an online public-service application used by people with older devices, intermittent connectivity, and diverse accessibility needs.
Multiple Choice Questions with Answers
Question 1
Which browser component is primarily responsible for converting parsed web resources into layout, painted output, and pixels?
A. Rendering engine
B. DNS resolver
C. Certificate authority
D. Database server
Correct Answer: A. Rendering engine
Question 2
In the URL https://example.com/items?id=7#details, which part is normally not sent to the server in the HTTP request?
A. The scheme
B. The host
C. The query string
D. The fragment
Correct Answer: D. The fragment
Question 3
What does HTTPS add to HTTP?
A. Guaranteed application correctness
B. TLS-based confidentiality, integrity, and server authentication
C. Automatic protection from all JavaScript vulnerabilities
D. A replacement for DNS
Correct Answer: B. TLS-based confidentiality, integrity, and server authentication
Question 4
Which status code class generally indicates a server-side failure?
A. 2xx
B. 3xx
C. 4xx
D. 5xx
Correct Answer: D. 5xx
Question 5
What is the principal purpose of the DOM?
A. To map domain names to IP addresses
B. To represent a document as an in-memory tree
C. To encrypt HTTP messages
D. To store server database records
Correct Answer: B. To represent a document as an in-memory tree
Question 6
Which statement best describes a single-page application?
A. It can never use a backend API
B. It always contains only one HTML element
C. It commonly changes views without loading a complete new document for every route
D. It cannot support server-side rendering
Correct Answer: C. It commonly changes views without loading a complete new document for every route
Question 7
Why should a frontend show loading and failure states for an API request?
A. Network requests are always instantaneous
B. Remote requests can be delayed, rejected, or fail
C. HTTP does not support successful responses
D. The DOM cannot display completed data
Correct Answer: B. Remote requests can be delayed, rejected, or fail
Question 8
Which practice is an example of progressive enhancement?
A. Making all functionality depend on one large script
B. Providing a usable form submission and adding asynchronous behaviour when JavaScript is available
C. Removing semantic HTML in favour of custom elements only
D. Disabling keyboard navigation
Correct Answer: B. Providing a usable form submission and adding asynchronous behaviour when JavaScript is available
Question 9
What does the same-origin policy primarily restrict?
A. A script's unrestricted reading of data from another origin
B. The browser's ability to parse HTML
C. The server's ability to use databases
D. The use of semantic elements
Correct Answer: A. A script's unrestricted reading of data from another origin
Question 10
Which statement about client-side validation is correct?
A. It makes server-side validation unnecessary
B. It is useful for feedback, but the server must still validate security-sensitive input
C. It automatically authorises every request
D. It replaces HTTPS
Correct Answer: B. It is useful for feedback, but the server must still validate security-sensitive input
Frontend Development using React.js or Angular
Chapter 1
of 14