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

Lazy Loading Images Progressively and Bundle An...

Lazy Loading Images Progressively and Bundle Analyzing

This talk was given at...

- FrontStack Conf in Lagos
- JSCon Mombasa, Kenya
- React Meetup Nairobi, Kenya

Shodipo Ayomide

March 25, 2020
Tweet

More Decks by Shodipo Ayomide

Other Decks in Technology

Transcript

  1. Lazy Loading Images Progressively and Bundle Analyzing SHODIPO AYOMIDE |

    FRONTSTACK.IO CONF, MEDIA ON THE WEB, LAGOS, NIGERIA
  2. Senior Developer Advocate Media Developer Expert at Cloudinary Community Evangelist

    @unStack @oscafrica @DevCLagos @NaijaHacks Hello! I am Shodipo Ayomide You can contact me at @developerayo on Twitter/GitHub https://shodipoayomide.com
  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 this image to

    pass 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. Lozad.js is a lightweight JS library to lazy load any

    HTML element such as images, videos Iframes and more.
  9. Import lozard.js into your project using the `import` command or

    via `CDN` wrapped in a `<script>` tag at the bottom of the page.
  10. 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.
  11. 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.
  12. Preloaders has been a fun thing before or now and

    would never be fun, but it might just be your only option at some point. In this case we are discussing preloading images first, a blog post always have that huge poster before the post that takes that little time to reload, how about you preload that image for a faster user experience?
  13. Install the webpack-bundle-analyzer via `NPM` or `YARN`. This will add

    the webpack-bundle-analyser to your `package.json` file.
  14. 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.
  15. By visiting the generated host you `127.0.0.1:88 88` to view

    the visuals of your JavaScript Bundles