Comments (1)
Implemented directive for lazy loading images:
import {Directive, ElementRef} from '@angular/core';
@Directive({
selector: 'img'
})
export class LazyImgDirective {
constructor(private elem: ElementRef) {
this.elem.nativeElement.setAttribute('loading', 'lazy');
console.log(this.elem.nativeElement);
}
}
<img
[src]="'https://image.tmdb.org/t/p/w' +
W342H513.WIDTH +
'/' +
movie.poster_path
"
[width]="W342H513.WIDTH"
[height]="W342H513.HEIGHT"
alt="poster movie"
[title]="movie.title"
/>
Stats:
List rendering 180ms
Used HTML attribute:
<img
loading="lazy"
[src]="'https://image.tmdb.org/t/p/w' +
W342H513.WIDTH +
'/' +
movie.poster_path
"
[width]="W342H513.WIDTH"
[height]="W342H513.HEIGHT"
alt="poster movie"
[title]="movie.title"
/>
Stats:
List rendering 144ms
Used href directly
<a
class="movies-list--grid-item"
*ngFor="let movie of movies; trackBy: movieById"
[href]="'/movie/' + movie.id"
>
<img loading="lazy">
</a>
Stats:
List rendering 123ms
from angular-movies-perf.
Related Issues (20)
- Initial linting report
- Setup Lighthouse audits in CI
- Organize for better bundling
- MovieTrailerComponent HOT 3
- Setup Linting Rules
- Implement global state to cache results
- Account Page
- Setup git hooks with husky, lint-staged and commitlint
- Categories Delete Modal
- Categories Add Modal
- Aligne UI and features with https://github.com/tastejs/next-movies
- Fix inconsistencies and bugs through rewrite
- Implement movies details page
- Remove zone.js
- remove form field HOT 1
- Remove MatButton and MatIcons HOT 2
- Update RxJS to v7 HOT 1
- Remove Animations Module HOT 1
- Optimize rendering, style recalculation and paint v1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-movies-perf.