Lazy loading

Uses your system voice; voice and rate in settings.

Snapshot

≈ 3 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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

Text derived from https://en.wikipedia.org/w/index.php?oldid=1324650611 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

Extracted from the cited revision's reference blocks; absent citations are not invented.