Hurry Up, Ends March 14!

LoadingStrategy

LoadingStrategy is an abstract class exposed by @abp/ng.core package. There are two loading strategies extending it: ScriptLoadingStrategy and StyleLoadingStrategy. Implementing the same methods and properties, both of these strategies help you define how your lazy loading will work.

API

constructor

constructor(
  public path: string,
  protected domStrategy?: DomStrategy,
  protected crossOriginStrategy?: CrossOriginStrategy
)
JavaScript
  • path is set to <script> elements as src and <link> elements as href attribute.
  • domStrategy is the DomStrategy that will be used when inserting the created element. (default: AppendToHead)
  • crossOriginStrategy is the CrossOriginStrategy that will be used on the created element before inserting it. (default: Anonymous)

Please refer to DomStrategy and CrossOriginStrategy documentation for their usage.

createElement

createElement(): HTMLScriptElement | HTMLLinkElement
JavaScript

This method creates and returns a <script> or <link> element with path set as src or href.

createStream

createStream(): Observable<Event>
JavaScript

This method creates and returns an observable stream that emits on success and throws on error.

ScriptLoadingStrategy

ScriptLoadingStrategy is a class that extends LoadingStrategy. It lets you lazy load a script.

StyleLoadingStrategy

StyleLoadingStrategy is a class that extends LoadingStrategy. It lets you lazy load a style.

Predefined Loading Strategies

Predefined loading strategies are accessible via LOADING_STRATEGY constant.

AppendAnonymousScriptToHead

LOADING_STRATEGY.AppendAnonymousScriptToHead(src: string, integrity?: string)
JavaScript

Sets given paremeters and crossorigin="anonymous" as attributes of created <script> element and places it at the end of <head> tag in the document.

PrependAnonymousScriptToHead

LOADING_STRATEGY.PrependAnonymousScriptToHead(src: string, integrity?: string)
JavaScript

Sets given paremeters and crossorigin="anonymous" as attributes of created <script> element and places it at the beginning of <head> tag in the document.

AppendAnonymousScriptToBody

LOADING_STRATEGY.AppendAnonymousScriptToBody(src: string, integrity?: string)
JavaScript

Sets given paremeters and crossorigin="anonymous" as attributes of created <script> element and places it at the end of <body> tag in the document.

AppendAnonymousStyleToHead

LOADING_STRATEGY.AppendAnonymousStyleToHead(href: string, integrity?: string)
JavaScript

Sets given paremeters and crossorigin="anonymous" as attributes of created <style> element and places it at the end of <head> tag in the document.

PrependAnonymousStyleToHead

LOADING_STRATEGY.PrependAnonymousStyleToHead(href: string, integrity?: string)
JavaScript

Sets given parameters and crossorigin="anonymous" as attributes of created <style> element and places it at the beginning of <head> tag in the document.

See Also

Contributors


Last updated: July 31, 2024 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

Community Talks

Real World Problems and Solutions with AI

27 Feb, 17:00
Online
Watch the Event
Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book