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 247

Vue, Angular & Svelte2 min read

Vue's v-once: Render Once, Then Ignore

Use v-once to render a part of your template exactly once. After the initial render, Vue treats it as static content, ignoring future data updates for that element and its children. This is a performance optimization for content that never needs to change.

Angular AOT: Compile Before the Browser
Vue, Angular & Svelte2 min read

Angular AOT: Compile Before the Browser

Angular's AOT compiler converts your app into efficient JavaScript during the build process, not in the browser. This means faster rendering and smaller bundles, as the compiler itself isn't shipped.

Vue, Angular & Svelte2 min read

Svelte Preprocessors: Write in Any Language

A Svelte preprocessor is a translator, converting code like TypeScript or SCSS into plain JS and CSS before compilation. This lets you use advanced tooling in .svelte files. The footgun is forgetting to configure it, leading to syntax errors.

Vue, Angular & Svelte1 min read

Vue Plugins: Add App-Wide Functionality

A Vue plugin packages reusable logic to add features across your entire app, like a global toolbox. Use them for routing, state management, or making custom functions globally available.

Vue, Angular & Svelte2 min read

Vue Render Functions: Trading Templates for JS Power

Render functions trade Vue's declarative templates for the full programmatic power of JavaScript. Use them for highly dynamic components where logic is too complex for templates. The footgun is losing template optimizations and readability for imperative code.

Headless Components: Separate Logic from UI
Vue, Angular & Svelte2 min read

Headless Components: Separate Logic from UI

A Headless Component separates a component's logic from its UI, providing the 'brain' without the 'looks'. Use it for complex elements like dropdowns that need consistent behavior but different visual styles. The footgun is assuming it's a drop-in UI.

Angular HttpInterceptor: A Pipeline for API Requests
Vue, Angular & Svelte2 min read

Angular HttpInterceptor: A Pipeline for API Requests

Think of an HttpInterceptor as a pipeline for every API call, letting you inspect or modify requests and responses globally. Use it to automatically add auth headers or show a loading spinner.

Angular Custom Attribute Directives
Vue, Angular & Svelte2 min read

Angular Custom Attribute Directives

An Angular attribute directive changes the appearance or behavior of an existing DOM element without adding a new one, applied as a plain HTML attribute so reusable behavior like hover effects or validation can be attached declaratively across many templates.

Vue, Angular & Svelte2 min read

Vue Composables: Reusable Stateful Logic

A Vue composable is a function for bundling reusable stateful logic, like tracking mouse position. Use it to share complex logic like API fetches across components. The footgun: each component gets a fresh, independent state, not a shared one.

Vue, Angular & Svelte2 min read

Vue Custom Directives: For Low-Level DOM Access

Vue custom directives are for low-level DOM access. Use them for tasks like auto-focusing a dynamically inserted input. The footgun is using them for stateful logic or UI structure, where a composable or component is the right tool.

Svelte Actions: Reusable DOM Logic
Vue, Angular & Svelte1 min read

Svelte Actions: Reusable DOM Logic

Svelte Actions let you run code when an element is mounted for direct DOM access. Use them to integrate third-party libraries or add custom events like swipe gestures.

Angular Custom Pipes: Transform Data in Your Templates
Vue, Angular & Svelte2 min read

Angular Custom Pipes: Transform Data in Your Templates

An Angular custom pipe is a reusable formatting function for your templates. Use it for common display transformations like currency or date formatting, keeping your component logic clean. Footgun: Avoid slow logic; pipes run often and can kill performance.

Angular Services: Your App's Shared Toolbox
Vue, Angular & Svelte2 min read

Angular Services: Your App's Shared Toolbox

An Angular service is a shared toolbox for your app. Instead of components building their own tools (like an HTTP client), they request a single instance from the dependency injector.

Vue, Angular & Svelte2 min read

Vue Router: Controlling Scroll Behavior

In a SPA, the browser doesn't manage scroll position; scrollBehavior is your manual override. Use it to scroll to top on new pages or restore position on back/forward. The footgun is forgetting savedPosition, breaking native back-button behavior.

Vue, Angular & Svelte2 min read

Router History vs. Hash Mode: URL Style and Server Setup

Router history mode determines your SPA's URL style. History mode uses clean URLs (/users) but needs server setup, while hash mode uses a hash symbol (/#/users) and works out-of-the-box.

Vue, Angular & Svelte2 min read

Vue Route Animations: Animating Page Changes

Animate between pages by wrapping your router view in a <transition> component, giving your SPA the feel of a native app. This is used for sliding or fading effects during navigation.

Angular: Reading URL Query Parameters
Vue, Angular & Svelte1 min read

Angular: Reading URL Query Parameters

Angular gives you two ways to read URL query params: a static snapshot for the initial value, or a queryParams Observable for live updates. Use it for values like ?search=term.

File-Based Routing: Your Filesystem is Your API
Vue, Angular & Svelte2 min read

File-Based Routing: Your Filesystem is Your API

File-based routing makes your directory structure the single source of truth for your app's URLs. Creating a file at routes/about/+page.svelte automatically creates the /about page, no central config needed.

Vue, Angular & Svelte2 min read

Navigation Guards: Vue's Route Bouncers

Think of navigation guards as bouncers for your app's routes. They intercept route changes to check permissions or fetch data before rendering a page. The old next() callback is a trap; accidentally calling it twice can break navigation.

Nested Routes: Mapping URLs to Component Trees
Vue, Angular & Svelte1 min read

Nested Routes: Mapping URLs to Component Trees

Nested routes map URL segments to components inside other components, like a sub-page within a main layout. This is common for user dashboards with sections like 'profile' and 'settings'. The footgun is forgetting the child router outlet.