Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63600051
lazy-image-load-directive.directive.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 21, 06:40
Size
636 B
Mime Type
text/x-java
Expires
Thu, May 23, 06:40 (2 d)
Engine
blob
Format
Raw Data
Handle
17793443
Attached To
rNIETZSCHEBETAAPP Nietzsche-Beta-App
lazy-image-load-directive.directive.ts
View Options
import { Directive, ElementRef } from '@angular/core';
@Directive({
selector: 'img'
})
export class LazyImageLoadDirectiveDirective {
constructor({ nativeElement }: ElementRef<HTMLImageElement>) {
const supports = 'loading' in HTMLImageElement.prototype;
if (supports) {
nativeElement.setAttribute('loading', 'lazy');
}
}
}
// IF NOT SUPPORTED IN CHROME: Open chrome://flags in Chromium or Chrome Canary.
// Search for lazy.
// Enable both the “Enable lazy image loading” and the “Enable lazy frame loading” flag.
// Restart the browser with the button in the lower right corner of the screen.
Event Timeline
Log In to Comment