load

Asynchronously load external ressources.

Methods

(async, static) css(href)

Asynchronously load a stylesheet from href.

Source:
Parameters:
Name Type Description
href String
Examples
// Load:
await load.css("my-styles.css")
// Preload:
const preloader = load.css("my-styles.css")

// Then wait for loading to finish:
await cssLoader

(async, static) js(href)

Asynchronously load a script from href.

Source:
Parameters:
Name Type Description
href String
Examples
// Load:
await load.js("my-script.js")
// Preload:
const preloader = load.js("my-script.js")

// Then wait for loading to finish:
await preloader

(async) styles(hrefopt)

Load cosmic-lib CSS from href or from default origin. All subsequent calls will refer to the original request.

Source:
Parameters:
Name Type Attributes Default Description
href string <optional>
'cosmic-lib.css'
Example
/// Preload at the start of your script:
cosmicLib.load.styles('css/cosmic-lib.css')

/// Then wait for the request to resolve before you display CosmicLink HTML
/// description:
await cosmicLib.load.styles()