Reducing initial bundle size, Zone.js is about 30KB raw and around 10KB gzipped. Remove it can significantly save the initial load time.
Avoid unnecessary change detection cycles: Zone.js notify Angular to run change detection on every async operation, but it doesn’t actually know whether these operations change any data.
Improve debugging experience, Zone.js can make stack traces harder to read.
Integration steps
Create an Angular 18 project
1
npx @angular/cli@18 new my-zoneless-app
Enable zoneless change detection in standalone bootstrap app.
Posted onEdited onInhtml Symbols count in article: 186Reading time ≈1 mins.
Introduction
How to implement lazy load images in html page?
Use loading=lazy attribute of img tag
With html5, you can use loading="lazy" attribute to lazy load images. This attribute tells the browser to defer loading of the image until it is needed. The browser will load the image when it is about to come into view.
1
<img src="image.jpg" loading="lazy" alt="描述性文字">
For old browsers which do not support loading attribute, you can use JavaScript to implement lazy load images.
1 2
<!-- HTML --> <imgdata-src="image.jpg"class="lazyload"alt="描述性文字">