Responsive design patterns with CSS media queries

Responsive design adapts layouts to different screen sizes. I use media queries with @media to apply styles conditionally based on viewport width. Mobile-first approach starts with mobile styles, then adds desktop features. Breakpoints at common devic

TypeScript fundamentals for type-safe front-end code

TypeScript adds static typing to JavaScript for better code quality. I define types with interfaces and type aliases for clear contracts. Type annotations like : string, : number catch errors at compile time. Generics enable reusable, type-safe compon

SVG manipulation with JavaScript

SVG (Scalable Vector Graphics) creates resolution-independent graphics. I manipulate SVG elements with DOM methods like createElementNS(). Attributes control SVG properties: setAttribute(), getAttribute(). Animations use CSS or SMIL for declarative ef

Canvas API for graphics and animations

The Canvas API provides a drawable bitmap surface for graphics. I use <canvas> elements with 2D rendering context via getContext('2d'). Drawing methods include fillRect(), strokeRect(), arc(), and lineTo(). The save() and restore() methods manag

WebSockets for real-time bidirectional communication

WebSockets enable real-time, full-duplex communication between client and server. I create WebSocket connections with new WebSocket(url) for persistent connections. The protocol uses ws:// or wss:// (secure) URLs. Events like onopen, onmessage, onerro

LocalStorage, SessionStorage, and IndexedDB

Web storage APIs persist data in the browser. I use localStorage for permanent client-side storage across sessions. The sessionStorage API stores data for single sessions that clears when tabs close. Both provide simple key-value storage with 5-10MB l

Front-end security - XSS and CSRF prevention

Front-end security protects users from malicious attacks. I prevent Cross-Site Scripting (XSS) by sanitizing user input and using textContent instead of innerHTML. Content Security Policy (CSP) headers restrict resource loading to trusted sources. Cro

Web Components and Shadow DOM encapsulation

Web Components create reusable custom elements with encapsulated functionality. I use Custom Elements API to define new HTML tags with customElements.define(). Shadow DOM provides style and markup encapsulation preventing CSS leakage. HTML Templates w

Progressive Web Apps - service workers and offline support

Progressive Web Apps (PWAs) combine web and native app features. I register service workers to intercept network requests and enable offline functionality. The service worker lifecycle includes install, activate, and fetch events. Cache API stores ass

Performance optimization - lazy loading and code splitting

Performance optimization reduces load times and improves user experience. I use code splitting to break bundles into smaller chunks loaded on demand. React's lazy() and Suspense enable component-level code splitting. Dynamic import() loads modules asy

State management with Context API and Redux patterns

State management solutions handle data flow in complex applications. I use React Context API for moderate state sharing without prop drilling. The createContext function creates context objects, while Provider passes data down the tree. The useReducer

React hooks - useState, useEffect, and custom hooks

React Hooks enable state and lifecycle features in function components. I use useState to add stateful values that persist between renders. The useEffect hook handles side effects like data fetching, subscriptions, and DOM manipulation. Dependencies a