Upgrade to Pro — share decks privately, control downloads, hide ads and more …

React Atlanta Conference - Progressive Imaging ...

Shodipo Ayomide
September 08, 2020
130

React Atlanta Conference - Progressive Imaging & Handling in WebPack

Conference for React Atlanta, covered lazy loading images in JavaScript, and Analyzing images using the webpack-bundle-analyzer.

Shodipo Ayomide

September 08, 2020
Tweet

More Decks by Shodipo Ayomide

Transcript

  1. Senior Developer Advocate GITHUB STAR Media Developer Expert at Cloudinary

    Community Lead @unStackAfrica @oscafrica @DevCLagos @NaijaHacks Hello! I am Shodipo Ayomide Twitter/Github: @developerayo https://shodipoayomide.com
  2. What is Lazy Loading The idea of Lazy Loading media

    files in the web helps reduce the risk of some of the web app performance problems to a minimal. Response time is drastically reduced, media files loading speed is increased.
  3. Used for tracking a user interaction with your web page

    but often slows down scrolling Scroll Event Listeners
  4. We indicated that the listener will never cancel the scroll

    event. `{passive: true}` That information enables browsers to scroll the page immediately, rather than after the listener has finished.
  5. We have `data-src` here because we want to hold this

    image and pass it through the Intersection Observer API
  6. Next we are creating an object `config` and setting it

    up with an `intersectionObser ver `example
  7. Finally, you iterate over all of your images and add

    them to the Observer instance and lazy load the image.
  8. Lazy Load Images everytime to increase performance Eager Loading helps

    you to load all your needed entities at once, powerful catching abilities. With Lazy Loading, we only retrieve just the amount of data, which we need in a single query.
  9. - blazy.js - blazy.js is a lightweight JavaScript library for

    lazy loading and multi-serving images, iframes, video and other resources. - LazyLoad - LazyLoad is a script that automatically loads images as they enter the viewport. - Lozad
  10. Lozad.js is a lightweight JS library to lazy load any

    media files or HTML elements such as images, videos Iframes and more.
  11. Import lozard into your project using the `import` command or

    via `CDN` wrapped in a `<script>` tag at the bottom of the page.
  12. Placeholders Cloudinary is a media transformation tool, using a placeholder

    with cloudinary, you’ll have to request for a low-quality image of 400 X 300 resolution, greystyle, 100% blurry picture from cloudinary.
  13. The Low-quality, blurry image would be sent first thanks to

    Cloudinary, then in 5 seconds fade-into the high quality image we requested for after they have been loaded properly.
  14. Install the webpack-bundle-analyzer via `NPM` or `YARN`. This will add

    the webpack-bundle-analyser to your `package.json` file.
  15. Once you have setup the webpack bundle-analyzer you then have

    to run the `npm run build` command in your terminal. and it’ll generate another host.
  16. Visit the generated host by clicking the IP, `127.0.0.1:88 88`

    to view the visuals of your JavaScript Bundles