Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87670377
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
Mon, Oct 14, 02:53
Size
636 B
Mime Type
text/x-java
Expires
Wed, Oct 16, 02:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21636551
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