DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

What Are Deferrable Views in Angular?

Angular’s @defer blocks can postpone eligible template dependencies until idle, viewport, interaction, or another trigger. Learn the eligibility rules and UX trade-offs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular deferrable views, written as @defer blocks, let you postpone loading eligible parts of a template until a chosen trigger occurs. Used carefully, they can reduce code needed for the initial render; they do not automatically lazy-load everything inside the block or guarantee better performance.

What a deferrable view does

An @defer block wraps template content whose eligible dependencies Angular can place in dynamic imports. The browser fetches those dependencies after the rest of the template has rendered and the block’s trigger fires. Angular describes the feature as reducing the initial bundle by deferring code not strictly needed for a page’s initial rendering (Angular’s deferred loading guide).

As an Amazon Associate I earn from qualifying purchases.

This can help initial loading and metrics such as LCP or TTFB, but the result depends on the application and how the block is used. Angular’s documentation does not establish a universal performance gain or percentage. Confirm the built output and measure the application rather than assuming a block improves its metrics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which dependencies Angular can defer

Eligible dependencies include components, directives, pipes, and associated component CSS. For a component, directive, or pipe to be deferred, it must be standalone and not referenced outside the @defer block in the same file. An outside reference includes a ViewChild query. Dependencies that are not standalone remain eagerly loaded even when their tags appear inside the block; transitive dependencies may still use NgModules.

Angular’s compiler creates dynamic imports for eligible dependencies, but does not guarantee their import order. If a dependency still appears in the eager bundle, check its standalone status and whether the same file references it elsewhere before investigating the trigger.

Choose when loading starts

Without an explicit trigger, a defer block uses on idle. Built-in triggers cover browser idle time, visibility, user input, immediate loading, and elapsed time. A when trigger instead watches a boolean expression. Multiple triggers separated by semicolons are OR conditions: the first one to fire starts loading. Angular also supports prefetch conditions, which fetch dependencies without changing the separate condition for displaying the block.

Trigger What starts loading Practical consideration
on idle The browser reports idle time. Can load without a user action; it may not be appropriate if the deferred content would shift the initial view.
on viewport The placeholder or specified reference element enters the viewport. Useful for content farther down the page. A placeholder or reference element is needed to observe the position.
on interaction The user interacts with the placeholder or specified reference element. Fits content requested through a click or keyboard action; provide an understandable placeholder.
on hover The user hovers over the placeholder or specified reference element. Relies on pointer hover, so it should not be the only route to important content for users who cannot hover.
on immediate Immediately after the non-deferred content has rendered. May load early enough to reduce the benefit of deferring; consider whether the content belongs in the initial view.
on timer After a specified duration. Choose a delay that makes sense for the user rather than treating elapsed time as evidence of intent.
when A boolean expression becomes truthy. This is a one-way transition: after the block switches, it does not return to its placeholder if the expression later becomes false.

For exact syntax and trigger behavior, see Angular’s defer triggers tutorial and @defer API reference. Nested blocks with the same trigger can load together and create cascading requests, so avoid nesting them that way when the extra requests would undermine the intended loading sequence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Give users clear placeholder, loading, and error states

A placeholder appears before the trigger fires; loading content can appear after fetching begins; error content can appear if loading fails. These are distinct optional blocks. Angular recommends a placeholder, and dependencies used in any of these three sub-blocks are eager rather than deferred. Keep them lightweight. The minimum option for a placeholder and the after and minimum options for loading content can help prevent brief, distracting flashes when downloads finish quickly. Angular demonstrates the block syntax in its loading, error, and placeholder tutorial.

What happens with SSR, SSG, and hydration

With server-side rendering or static-site generation, the default behavior is to render the placeholder—or nothing if there is no placeholder. Defer triggers do not run on the server. The client hydrates the placeholder and then activates the triggers.

Incremental hydration offers a separate option: a hydrate trigger can let the main template render during SSR or SSG while its dependencies remain deferred for client-side hydration. Angular also documents event replay for matching events that occur before hydration completes. These behaviors are covered in the incremental hydration guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect layout stability and accessibility

Deferring visible content can make the page jump when it appears. Reserve enough space for the eventual content, or prioritize deferring sections below the fold. A trigger that fires during initial rendering can still cause layout shift if the block’s content changes the page after the initial layout.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Screen readers may announce the placeholder but not announce its replacement. Angular’s accessibility guidance demonstrates placing the changing region in a polite live region with aria-atomic="true" so assistive technology can announce updates. Ensure the placeholder itself communicates what is available or what action is needed, and do not make hover the sole way to access important content.

Why a trigger may seem to be ignored in development

Angular documents that when hot module replacement (HMR) is enabled, @defer dependencies load eagerly instead of waiting for configured triggers, including client-side and incremental-hydration triggers. If you are checking trigger behavior locally, disable HMR; Angular’s NG0751 error reference describes this development-mode caveat.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.