SPComponentLoader class

Component loader. Needs to be initialized with an implemented ISPComponentLoader.

Methods

getManifests()

Returns static copies of all the manifests.

loadComponent(manifest)

Loads a component from a manifest.

loadComponentById(id, version)

Resolve a component id and version, and load it.

loadCss(url)

Inserts a <link ... /> tag for a stylesheet.

loadScript(url, options)

Given a URL, load a script.

Method Details

getManifests()

Warning

This API is now deprecated.

this method will be removed in a future release.

Returns static copies of all the manifests.

static getManifests(): IClientSideComponentManifest[];

Returns

loadComponent(manifest)

Loads a component from a manifest.

static loadComponent<TComponent>(manifest: IClientSideComponentManifest): Promise<TComponent>;

Parameters

manifest
IClientSideComponentManifest

Manifest of the module to load.

Returns

Promise<TComponent>

A promise containing the loaded module.

loadComponentById(id, version)

Resolve a component id and version, and load it.

static loadComponentById<TComponent>(id: string, version?: string): Promise<TComponent>;

Parameters

id

string

The id of the component to load.

version

string

The version of the component to load. If version is not defined, the method will load any version of the component.

Returns

Promise<TComponent>

A promise containing the loaded module.

loadCss(url)

Inserts a <link ... /> tag for a stylesheet.

static loadCss(url: string): void;

Parameters

url

string

The CSS file URL.

Returns

void

loadScript(url, options)

Given a URL, load a script.

static loadScript<TModule>(url: string, options?: ILoadScriptOptions): Promise<TModule>;

Parameters

url

string

The script URL.

options
ILoadScriptOptions

globalExportsName: If the script isn't an AMD module and loads a global member on the page, specify the global member's name.

Returns

Promise<TModule>

A promise containing the loaded module.

Remarks

If a script with a global variable is being loaded, the global variable already exists, and the script fails to load (because of a syntax error, for example), the original global variable may be returned and an error may not be propagated.