Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F71337789
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
Thu, Jul 11, 04:16
Size
636 B
Mime Type
text/x-java
Expires
Sat, Jul 13, 04:16 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
18939332
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