preloadModule
Starts loading an ES module the page will import, so the import does not wait for the module graph to be discovered.
Starts loading an ES module the page will import, so the import does not wait for the module
graph to be discovered. React's preloadModule.
Import#
ts
import { preloadModule } from "@shadow-js/web";
Signature#
ts
function preloadModule(href: string, options?: CrossOriginOptions): void
Parameters#
| Name | Description |
|---|---|
href |
An http(s) or relative URL of the module. |
options |
CORS mode. Undefined adds no crossorigin attribute. |
Throws#
- TypeError (production message
SHADOW_RESOURCE_HINT_URL) for a URL that is not http(s) or relative.
Examples#
ts
import { preloadModule } from "@shadow-js/web";
preloadModule("/chunks/editor.js");