e01.org

Lazy loading

Lazy loading (also known as asynchronous loading) is a technique used in computer programming, especially web design and web development, to defer initialization of an object until it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used. This makes it ideal in use cases where network content is accessed and initialization times are to be kept at a minimum, such as in the case of web pages. For example, deferring loading of images on a web page until they are needed for viewing can make the initial display of the web page faster. The opposite of lazy loading is eager loading.

Lazy loading (also known as asynchronous loading) is a technique used in computer programming, especially web design and web development, to defer initialization of an object until it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used. This makes it ideal in use cases where network content is accessed and initialization times are to be kept at a minimum, such as in the case of web pages. For example, deferring loading of images on a web page until they are needed for viewing can make the initial display of the web page faster. The opposite of lazy loading is eager loading. @NgModule({ imports: [ BrowserModule, RouterModule.forRoot([ {path: , component: HomeComponent}, {path: 'product', component: ProductDetailComponent}, {path: 'luxury', loadChildren: () => import('./luxury.module').then(m => m.LuxuryModule), data: {preloadme: true} } ] // , {preloadingStrategy: CustomPreloadingStrategy} ) ], declarations: [ AppComponent, HomeComponent, ProductDetailComponent], providers:[{provide: LocationStrategy, useClass: HashLocationStrategy}, CustomPreloadingStrategy], bootstrap: [ AppComponent ] }) private int _myWidgetID; private Widget _myWidget = null; public Widget MyWidget { get { if (_myWidget == null) { _myWidget = Widget.Load(_myWidgetID); } return _myWidget; } } Or alternatively, with the null-coalescing assignment operator ??= private int _myWidgetID; private Widget _myWidget = null; public Widget MyWidget { get => _myWidget ??= Widget.Load(_myWidgetID); } This method is the simplest to implement, although if null is a legitimate return value, it may be necessary to use a placeholder object to signal that it has not been initialized. If this method is used in a multithreaded application, synchronization must be used to avoid race conditions. $userData = array ( "UID" = > uniqid(), "requestTime" => microtime(true), "dataType" => "", "request" => "" ); if (isset($_POST['data']) && $userData) { // ... } private ValueHolder valueHolder; public Widget MyWidget => valueHolder.GetValue(); ==External links== Lazy Loading, Mozilla Developer Network URLs, WHATWG HTML Standard JS Lazy Loading

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Lazy loading". 1764364019. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1324650611

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·