October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Use Promise.allSettled() to Load Optional Widgets Without Blocking Core Content

Render core content on its own path, then use Promise.allSettled() to handle each optional widget’s result without letting failures block the page.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render or reveal the page’s core content on its own path, then start optional widget requests independently. Promise.allSettled() lets you handle each widget’s success or failure separately—but it waits for every input to settle, so awaiting it before rendering core content would still block that content.

Keep optional widgets off the core rendering path

Separate required data from enhancements. Load and render the content the page needs first; start recommendations, related articles, weather, or other optional widgets without making core rendering depend on their results.

As an Amazon Associate I earn from qualifying purchases.

Promise.allSettled() aggregates promise outcomes. It does not make requests finish sooner, cancel slow work, or move JavaScript off the main thread. If you call it from the core path and wait for it before rendering, the page still waits for the slowest widget.

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

Start widget requests together and handle each outcome

For independent widgets, start each loader and pass the resulting promises to Promise.allSettled(). Once every promise has settled, inspect each result and update only its corresponding container.

renderCoreContent(coreData);

const widgetLoads = [
  loadRecommendations(),
  loadRelatedArticles(),
  loadWeather(),
];

Promise.allSettled(widgetLoads).then((results) => {
  const [recommendations, articles, weather] = results;

  if (recommendations.status === "fulfilled") {
    renderRecommendations(recommendations.value);
  } else {
    reportWidgetError("recommendations", recommendations.reason);
    showWidgetFallback("recommendations");
  }

  if (articles.status === "fulfilled") {
    renderRelatedArticles(articles.value);
  } else {
    reportWidgetError("articles", articles.reason);
    showWidgetFallback("articles");
  }

  if (weather.status === "fulfilled") {
    renderWeather(weather.value);
  } else {
    reportWidgetError("weather", weather.reason);
    showWidgetFallback("weather");
  }
});

The array of outcomes follows the input order. Keep the result handling aligned with the promise array; a positional mismatch can send one widget another widget’s data. Each result has a status of "fulfilled" or "rejected". Read value only for fulfilled results and reason only for rejected ones. (See MDN’s Promise.allSettled() reference.)

Use async/await without making the core wait

An async function can await required core data, render it, and only then await optional widget work. The await pauses that function at the aggregate; other program activity can continue, but later statements in that function wait for the widgets.

async function loadPage() {
  const coreData = await loadCoreData();
  renderCoreContent(coreData);

  const results = await Promise.allSettled([
    loadRecommendations(),
    loadRelatedArticles(),
  ]);

  updateOptionalWidgets(results);
}

Here, the core-data request is required, so it remains on the core path. The optional requests are aggregated only after core content has been rendered. If the application’s rendering framework delays making that content visible until loadPage() finishes, adjust the rendering boundary so optional work does not gate that visibility.

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

Associate results with widget identity

For a changing set of widgets, keep identifiers alongside loaders rather than relying on a manually maintained list of result variables. The index still connects each outcome to its input, so preserve the same array when mapping results.

const optionalWidgets = [
  { id: "recommendations", load: loadRecommendations },
  { id: "articles", load: loadRelatedArticles },
];

const results = await Promise.allSettled(
  optionalWidgets.map(({ load }) => load()),
);

results.forEach((result, index) => {
  const { id } = optionalWidgets[index];

  if (result.status === "fulfilled") {
    renderWidget(id, result.value);
  } else {
    reportWidgetError(id, result.reason);
    hideWidgetOrShowFallback(id);
  }
});

Choose between Promise.all() and Promise.allSettled()

Method Failure behavior What you get Best fit
Promise.all() Rejects as soon as an input rejects. Other operations continue, but their outcomes are not included in the rejected aggregate. A combined array of values if every input fulfills; otherwise a rejection. Results are jointly required, and one failure should fail the combined operation.
Promise.allSettled() Does not reject just because an input rejects; fulfills after all inputs settle. An outcome record for every input, indicating fulfillment or rejection. Tasks are independent and each result should be handled separately, as with optional widgets.

Neither method is a performance shortcut: both aggregate promises, and neither makes the browser render content sooner by itself. Choose according to whether tasks are jointly required or independently useful. (See MDN’s Promise.all() reference.)

Handle slow, failed, and visually disruptive widgets

  • A rejection: show an appropriate fallback or omit that widget while leaving unrelated widgets and core content intact. Record the failure for debugging or monitoring rather than silently treating a broader outage as success.
  • A promise that never settles: keeps the aggregate pending indefinitely. Promise.allSettled() is not a timeout; implement a separate deadline or cancellation policy if the interface requires one.
  • A late layout change: reserve space where practical or show a clear loading or empty state, so a widget’s eventual appearance is less disruptive to the page layout.
  • Heavy synchronous work: promise aggregation does not prevent JavaScript from occupying the main thread and delaying rendering or interaction.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make the loading strategy match the rendering goal

Promises control how asynchronous outcomes are coordinated; browser resource loading and rendering strategy are separate concerns. Keep non-critical resources and JavaScript out of the critical rendering path, defer non-critical scripts when appropriate, and minimize main-thread work. A blocking script can delay parsing or painting before promise handling has any chance to help. See MDN’s lazy-loading guide, MDN’s critical rendering path guidance, and MDN’s guidance on optimizing long tasks.

MDN’s lazy-loading guide reports historical median resource-weight figures for 2011–2019: approximately 100–400 KB on desktop and 50–350 KB on mobile. Those historical figures are context about resource growth, not current measurements or evidence of a performance gain from Promise.allSettled().

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

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.