Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

4330 bites

Page 190

Programmatically change SPA URL without reload and what is state for?
TypeScript & Web APIs2 min read

Programmatically change SPA URL without reload and what is state for?

This tests History API fluency. Answer: use pushState or replaceState to change the URL silently; the state object is serializable data tied to the history entry, surfaced through popstate on back or forward navigation.

Which Web API offloads expensive work from the main UI thread?
TypeScript & Web APIs2 min read

Which Web API offloads expensive work from the main UI thread?

Cite Web Workers, instantiate new Worker(url), and communicate via postMessage and onmessage.

What is a Service Worker's role and key PWA capability?
TypeScript & Web APIs2 min read

What is a Service Worker's role and key PWA capability?

Tests understanding of the Service Worker as a network proxy and its core PWA benefit. A strong answer states it intercepts requests as a proxy and enables offline use via granular caching. Red flag: confusing it with Web Workers or DOM manipulation.

SPA back button: what event fires and how do you handle it?
TypeScript & Web APIs2 min read

SPA back button: what event fires and how do you handle it?

Tests History API literacy. Strong answer: popstate event, PopStateEvent type, restore UI via event.state, and zero-delay setTimeout for DOM sync. Red flag: confusing popstate with pushState or using hashchange for modern History API routing.

Pass data to a Web Worker and transfer an ArrayBuffer efficiently
TypeScript & Web APIs2 min read

Pass data to a Web Worker and transfer an ArrayBuffer efficiently

Tests postMessage clone versus transferable objects for zero-copy transfer. Good answers note postMessage copies by default, but ArrayBuffer can move via transfer list, neutering the original.

Describe the Service Worker lifecycle and cache versioning
TypeScript & Web APIs2 min read

Describe the Service Worker lifecycle and cache versioning

Tests your grasp of the Service Worker lifecycle and cache versioning. A strong answer sequences register, install, activate, and fetch; notes install precaches assets while activate purges old caches and finalizes takeover.

Explain Network First vs Cache First caching and when to use each
TypeScript & Web APIs2 min read

Explain Network First vs Cache First caching and when to use each

Tests matching caching strategy to asset freshness. Cache First serves static assets from the Cache API, falling back to network. Network First fetches fresh content, falling back to cache offline.

TypeScript & Web APIs2 min read

Dedicated vs Shared vs Service Workers compared

Dedicated worker serves one page for offloading CPU; Shared worker is one instance across same-origin contexts via ports; Service worker is a network proxy for caching and push, event-driven and killable.

Design a Service Worker caching strategy for a news app
TypeScript & Web APIs2 min read

Design a Service Worker caching strategy for a news app

Cache First for the app shell, Stale-While-Revalidate for static assets, and Network First for article APIs.

How do you programmatically play, pause, and dynamically set a video source?
TypeScript & Web APIs2 min read

How do you programmatically play, pause, and dynamically set a video source?

Your grasp of HTMLMediaElement's imperative API and the play() Promise. Query the video, attach play() and pause() to buttons, and set src or swap source children then call load(). Treating play() as synchronous or changing src without load().

Get canvas 2D context and draw a filled circle
TypeScript & Web APIs2 min read

Get canvas 2D context and draw a filled circle

This tests Canvas API coordinates and context acquisition. A strong answer selects the canvas, calls getContext("2d"), uses path functions for circles, sets color style, and fills. A red flag is ignoring the top-left origin or using SVG instead.

Write a TypeScript async/await function that requests webcam access and handles errors
TypeScript & Web APIs2 min read

Write a TypeScript async/await function that requests webcam access and handles errors

This tests async/await error handling for getUserMedia and stream attachment. A good answer uses try/catch, sets video.srcObject, and branches on NotAllowedError and NotFoundError. A red flag is omitting catch or using src instead of srcObject.

How do you create a smooth Canvas 2D loop with requestAnimationFrame?
TypeScript & Web APIs2 min read

How do you create a smooth Canvas 2D loop with requestAnimationFrame?

Tests render pipeline timing. Outline: queue rAF per refresh; derive delta from timestamp for frame-rate independence; recurse each frame; cancel via cancelAnimationFrame. Red flag: claiming rAF locks 60fps, ignoring timestamp, or setInterval is fine.

Which video event signals completion, and how do you track playback time?
TypeScript & Web APIs2 min read

Which video event signals completion, and how do you track playback time?

Tests HTMLMediaElement events and UI performance. Answer: use ended for replay; read currentTime on timeupdate but throttle updates or use requestAnimationFrame. Red flag: setInterval polling, currentTime===duration checks, or unthrottled state writes.

Explain the roles of vertex and fragment shaders in WebGL
TypeScript & Web APIs2 min read

Explain the roles of vertex and fragment shaders in WebGL

Vertex shaders write gl_Position per vertex; fragment shaders write gl_FragColor per pixel.

Use MediaRecorder to capture a canvas stream and download as WebM
TypeScript & Web APIs2 min read

Use MediaRecorder to capture a canvas stream and download as WebM

Tests MediaRecorder lifecycle and blob assembly. Answer: canvas.captureStream() into new MediaRecorder with video/webm, start(), collect chunks via dataavailable, stop(), then build a Blob and object URL for download.

In WebGL, what is the difference between attributes and uniforms?
TypeScript & Web APIs2 min read

In WebGL, what is the difference between attributes and uniforms?

Tests per-vertex versus per-draw-call data flow. Attributes vary per vertex from buffers; uniforms are constant per draw call. Cite vertex positions as attributes and an MVP matrix as uniform.

TypeScript & Web APIs2 min read

WebRTC signaling: SDP, ICE, and the signaling server

Peers exchange SDP offer and answer describing media via an out-of-band signaling server, then trade ICE candidates to find a network path using STUN and TURN.

TypeScript & Web APIs1 min read

First compilerOptions to set after tsc --init

Enable strict for full type safety, set target and module to match the runtime, and choose outDir/rootDir or moduleResolution; each tightens checks or aligns output.

TypeScript & Web APIs2 min read

What is tsconfig strict, and which sub-flag to relax for legacy?

Tests strict as a master switch and migration pragmatism. Strong answers name strictNullChecks or noImplicitAny as the first to relax in legacy code, trading null-safety for fewer errors. Red flag: disabling strict entirely instead of a targeted sub-flag.