JavaScript Dynamic Import Retry: Recover From Failed Module Loads
Learn why failed JavaScript dynamic imports could remain broken after a network interruption, which browsers now support retries, and how to test recovery without breaking older clients.
On this page
A temporary network failure can leave a web app unable to load a JavaScript module even after the connection recovers. A change to browser module loading is beginning to fix that problem: failed module fetches can be retried instead of remaining stuck as cached failures for the rest of the page session. The change is arriving incrementally across browsers, so developers need to understand both the new behavior and the compatibility gaps before removing their existing recovery code.
Why a failed JavaScript import could keep failing
JavaScript's import() expression lets a website load code only when a feature is needed. A shopping site, for example, might defer loading its checkout interface until a customer opens the cart, keeping that code out of the initial page load. The expression returns a promise, which either supplies the module's exports or rejects when loading or evaluation fails. That makes it possible to display an error and offer the user another attempt.
The trouble was that browsers could remember a failed module fetch in their internal module map, the per-page record of module-loading results. If a request for ./checkout.js failed because the network briefly dropped or the server returned an error, another call to import("./checkout.js") could immediately fail again without making a fresh request. Refreshing the entire page might clear the immediate problem, but it also discards the user's current interface state and can interrupt an unfinished task.
This behavior was not the same as an ordinary failed request made with the Fetch application programming interface (API). A failed fetch can be followed by another request, subject to normal network and HTTP caching behavior. With module imports, the browser's module map could preserve the failure itself, preventing a straightforward retry from reaching the network at all.
Browser updates make failed module imports retryable
The change follows a proposal to the Hypertext Markup Language (HTML) standard that stops caching failed module-fetch results in the same way as successful module loads. The proposal, tracked in the WHATWG HTML specification project, addresses a problem developers had raised for years: a transient loading error could make a lazy-loaded feature unusable until the page was reloaded. The revised behavior allows a later import attempt to fetch the module again after a loading failure.
Firefox 155 introduced support for retryable module loading in September 2026, and Chrome 156 added support in October 2026. The feature remains unevenly supported: browser compatibility information does not yet list Safari or Microsoft Edge as supporting it, despite other recent browser updates involving module loading. Developers should verify the exact browser versions and embedded browser runtimes used by their audience rather than treating the standard change as universal.
The change covers dynamic imports, as well as module scripts inserted dynamically into a page. It also affects static import declarations when they occur within a module that is itself loaded through one of those mechanisms. The practical gain is narrow but valuable: after a genuine fetch failure, the browser can make another attempt without requiring the application to invent a different module URL.
Retry the import without changing the module URL
In a supporting browser, the simplest retry is to call import() again with the same module specifier after the original loading failure. The specifier is the path or identifier that tells the browser which module to load. For example, a page that loads its reporting screen only when requested can retry the same module after a temporary network error.
async function loadReports() {
try {
const reports = await import("./reports.js");
reports.render();
} catch (error) {
console.error("Could not load reports:", error);
// Offer the user a retry action.
}
}
This example catches the failure and leaves the retry decision to the application. A retry button can call loadReports() again after the user chooses to try once more. In a browser that supports retryable module loading, a failed network fetch is no longer necessarily a permanent obstacle for that page session. In an older browser, however, calling the function again may reproduce the same failure.
It is also important to distinguish fetching a module from evaluating it. The new behavior addresses failures while retrieving or linking module code, such as a network error or an unsuccessful HTTP response. If the module loads successfully but its own code throws an exception during evaluation, repeating the import is not a general-purpose way to reset the module or undo its side effects. Developers should identify which stage failed before deciding what recovery makes sense.
Do not confuse a retryable import with a guaranteed recovery
A second import attempt does not guarantee success. The server might still be unavailable, the file might genuinely not exist, or the response might have an incorrect content type. Cross-origin restrictions can also prevent a module from loading when the server's permissions are configured incorrectly. Retryable loading simply gives a temporary fetch failure a chance to recover when the underlying cause has disappeared.
Repeated retries can make a bad situation worse if an application starts them automatically without limits. A robust interface should avoid launching several identical imports at once, provide clear feedback, and stop retrying after a reasonable number of attempts. For a user-facing operation such as checkout, preserve the form state and make sure the recovery process does not accidentally submit a payment or create duplicate transactions.
Older compatibility workarounds sometimes append a unique query parameter to a module URL to force the browser to treat the import as a different entry. That approach can bypass some cached failures, but it also creates distinct module identities and can cause repeated evaluation or memory growth in a long-running page. It should not be the default response to every import error, particularly now that browser support for the standard retry behavior is improving.
Test network failures separately from application errors
Before changing a production recovery strategy, test what happens when a module request fails once and then succeeds. Browser developer tools can simulate an offline connection, while a controlled test server can return a temporary error for the first request and a valid JavaScript module for the next. Check whether the second import generates a new network request and whether the feature becomes usable without reloading the page.
Run the same test across the browser versions your application supports. Include a permanently missing module and a module that throws during evaluation, because those failures should not be treated as interchangeable with a temporary network interruption. Confirm that the interface remains stable after a failed attempt and that a successful retry does not register duplicate event handlers or repeat initialization side effects.
Frameworks and bundlers deserve special attention. Some applications load split JavaScript chunks through generated import paths and add their own retry logic around those requests. Removing that logic simply because one browser now retries failed imports could break users on unsupported browsers. Keep application-level recovery until compatibility data and production testing show that the browsers you support behave as expected.
What web developers should change now
For new code, handle rejected imports explicitly and provide a useful recovery path instead of assuming that the browser will recover automatically. For existing applications, audit custom dynamic-import retry helpers, especially workarounds that alter module URLs to escape cached failures. Keep those fallbacks where they are needed for older browsers, and avoid relying on a browser feature that has not reached all of your supported environments.
The most useful outcome is not that every JavaScript loading problem disappears. It is that a temporary failure no longer has to become a page-session failure in browsers implementing the updated behavior. As support spreads, developers can simplify some defensive code, but the deciding evidence should be successful cross-browser testsβnot the presence of a new feature name in release notes.
Share this post
Written by



