Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79749008
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
Wed, Aug 28, 01:24
Size
636 B
Mime Type
text/x-java
Expires
Fri, Aug 30, 01:24 (2 d)
Engine
blob
Format
Raw Data
Handle
20224255
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