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.

8668 bites

Page 246

Vue, Angular & Svelte2 min read

Vue's <script setup>: Less Boilerplate, More Performance

Vue's <script setup> is compile-time sugar that automatically exposes variables and functions to your template, cutting boilerplate. It yields more succinct, performant components with better type-safety.

Configuring the Angular Compiler (ngc)
Vue, Angular & Svelte2 min read

Configuring the Angular Compiler (ngc)

The Angular Compiler (ngc) transforms your templates into optimized JavaScript ahead-of-time. You tune it in tsconfig.json to create smaller production builds or publish reusable libraries.

Angular Ivy: The Tree-Shakable Compiler
Vue, Angular & Svelte2 min read

Angular Ivy: The Tree-Shakable Compiler

Angular's Ivy engine compiles components like separate puzzle pieces, making apps smaller and faster. This enables effective tree-shaking for smaller bundles and faster rebuilds.

Vue, Angular & Svelte2 min read

Vue Single-File Components (SFCs)

Vue's Single-File Components (SFCs) bundle a component's template, logic, and styles into one .vue file. A build tool compiles this into browser-readable JS and CSS, turning your template into optimized render functions.

Vue, Angular & Svelte2 min read

Vue's Virtual DOM: Efficient UI Updates

Vue keeps a JavaScript copy of the UI (the Virtual DOM) in memory. When data changes, it compares a new virtual tree to the old one and efficiently updates only the changed parts of the real DOM, avoiding costly full re-renders.

Vue, Angular & Svelte2 min read

Playwright: E2E Tests That Aren't Flaky

Playwright makes E2E tests reliable by automatically waiting for UI elements to be ready. Use it to test critical user journeys across Chrome, Firefox, and WebKit. The footgun is using brittle CSS selectors instead of user-facing locators like getByRole.

Angular's TestBed: A Sandbox for Component Testing
Vue, Angular & Svelte2 min read

Angular's TestBed: A Sandbox for Component Testing

Angular's TestBed creates a mini-app just for your test, letting you check how a component renders and behaves with mock dependencies. It's for testing component-template interactions in isolation.

Vitest Mocking: Isolating Code with `vi.mock`
Vue, Angular & Svelte2 min read

Vitest Mocking: Isolating Code with `vi.mock`

Vitest's vi.mock replaces a module with a fake version, isolating your code for tests. This is key for preventing real network or database calls. The footgun: calls are "hoisted" to the top of the file, running before other code and breaking variable access.

Vue, Angular & Svelte2 min read

Svelte Testing Library: Test Components Like a User

Test Svelte components like a user would use them. Svelte Testing Library interacts with the rendered DOM, not internal state, to verify behavior. This avoids brittle tests tied to implementation.

The Testing Trophy: Prioritize Integration Tests
Vue, Angular & Svelte2 min read

The Testing Trophy: Prioritize Integration Tests

The Testing Trophy flips the classic pyramid, arguing for "mostly integration tests" to maximize your return on investment. It's for UI apps where testing component interactions gives more confidence than isolated unit tests.

Cypress Component Testing: Test in a Real Browser
Vue, Angular & Svelte2 min read

Cypress Component Testing: Test in a Real Browser

Cypress component testing mounts your UI components in a real browser, not a simulated DOM, so you test them exactly as users see them. Use it for faster feedback on individual React, Vue, or Angular components.

Vue, Angular & Svelte2 min read

Unit Testing Vue Components with Vitest

Think of it as a two-part system: Vue Test Utils mounts your component in a virtual environment, and a runner like Vitest executes the test and reports pass/fail. Use this to verify a component's logic in isolation.

Angular Unit Testing: Jasmine & Karma
Vue, Angular & Svelte2 min read

Angular Unit Testing: Jasmine & Karma

Jasmine is your testing script (expect(a).toBe(b)), while Karma is the stage that runs it in a browser. This is Angular's default stack for unit testing components and services to ensure they work in isolation.

Partial Hydration: Interactive Islands in a Static Sea
Vue, Angular & Svelte2 min read

Partial Hydration: Interactive Islands in a Static Sea

Partial hydration makes sites faster by treating interactive UI as "islands" in a sea of static HTML, loading JavaScript only where needed. It's ideal for content-heavy pages. The biggest challenge is managing state between these isolated interactive islands.

Svelte's Legacy immutable={true} Optimization
Vue, Angular & Svelte2 min read

Svelte's Legacy immutable={true} Optimization

The immutable={true} option was a contract with the Svelte 3/4 compiler: you promise to never mutate data, and it uses fast referential checks for updates. It was a performance boost for immutable patterns.

Angular's ChangeDetectorRef: Manually Triggering Updates
Vue, Angular & Svelte2 min read

Angular's ChangeDetectorRef: Manually Triggering Updates

Angular's ChangeDetectorRef is your manual override for change detection. Use it when updates from outside Angular's zone (like third-party libraries) don't refresh the UI. The footgun is overuse, which can mask performance issues or cause lifecycle errors.

Vue, Angular & Svelte2 min read

JavaScript Bundle Analysis: Seeing Your App's Weight

Think of it as an X-ray for your compiled JavaScript, showing which libraries take up the most space. Use it to diagnose slow load times by finding large or duplicated dependencies.

List Virtualization: Rendering the Viewport, Not the Dataset
Vue, Angular & Svelte2 min read

List Virtualization: Rendering the Viewport, Not the Dataset

List virtualization renders only the visible slice of a huge dataset, keeping your app fast by maintaining a tiny DOM. Use it for long lists or infinite scroll feeds.

Angular's OnPush: Faster Apps by Doing Less
Vue, Angular & Svelte2 min read

Angular's OnPush: Faster Apps by Doing Less

OnPush tells Angular to only re-render a component when its inputs change or its own events fire, not on every global event. It's a key performance boost for large apps, but mutating an input object directly won't trigger a re-render, causing a stale UI.

Vue, Angular & Svelte2 min read

Vue Async Components: Defer Loading Until Needed

Vue async components defer loading a component's code until it's rendered, speeding up initial app loads. Use them for heavy components not needed right away, like modals or admin panels. The footgun is a blank UI if you don't handle loading/error states.