Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Lazy loading images With the intersection observer
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Juan
November 06, 2018
Programming
0
86
Lazy loading images With the intersection observer
Juan
November 06, 2018
Tweet
Share
More Decks by Juan
See All by Juan
An exciting intro to JavaScript unit testing
juanlizarazo
1
190
Dom manipulation in web workers: The future of your mobile web apps
juanlizarazo
0
91
Create instant loading mobile web pages with AMP
juanlizarazo
0
130
AMP - Accelerated Mobile Pages
juanlizarazo
0
40
Other Decks in Programming
See All in Programming
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
410
NOT A HOTEL - 建築や人と融合し、自由を創り出すソフトウェア
not_a_hokuts
2
900
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
510
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
130
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
150
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
360
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
190
あなたはユーザーではない #PdENight
kajitack
4
340
AIに任せる範囲を安全に広げるためにやっていること
fukucheee
0
120
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
160
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
220
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
310
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.4k
Typedesign – Prime Four
hannesfritz
42
3k
Deep Space Network (abreviated)
tonyrice
0
86
The Language of Interfaces
destraynor
162
26k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
RailsConf 2023
tenderlove
30
1.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.8k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
LAZY LOADING IMAGES WITH THE INTERSECTION OBSERVER SLC Front end
DEV
I ❤ • OPEN SOURCE @AMPHTML • INSTRUCTOR @UDEMY •
ENGINEERING @IMPARTNERPRM • !" @juanlizarazog HI! I AM JUAN LIZARAZO
@juanlizarazog AMPPROJECT.ORG BUILDING THE FUTURE WEB, TOGETHER. THE AMP PROJECT
@juanlizarazog What’s lazy loading?
@juanlizarazog Bounce rate
@juanlizarazog
PERFORMANCE MATTERS! @juanlizarazog
LAZY LOADING RESOURCES MATTER! @juanlizarazog
@juanlizarazog Our Goal Complete first meaningful render under 1 second
Image Lazy loading @juanlizarazog
@juanlizarazog No. 1 Element.getClientBoundingRect()
@juanlizarazog const domRect = element.getBoundingClientRect(); { "x": 418.4375, "y": 172,
"width": 923.328125, "height": 44, "top": 172, "right": 1341.765625, "bottom": 216, "left": 418.4375 }
@juanlizarazog DOMRect is just a rectangle
@juanlizarazog element.getBoundingClientRect(); 1. element.getClientRects(); 2. Returns a DOMRectList 3. Returns
the union of these rectangles which is the DOMRect returned by element.getBoundingClientRect(); * Amount of scrolling matters
@juanlizarazog VIEW PORT
@juanlizarazog Let’s see it
@juanlizarazog No. 2 new IntersectionObserver(callback, options);
@juanlizarazog IntersectionObservers let you know when an observed element enters
or exits the browser’s viewport.
@juanlizarazog const options = { root: null, rootMargin: '0px', threshold:
0 } const observer = new IntersectionObserver( callback, options );
@juanlizarazog That’s it, so let’s see it
@juanlizarazog Love your users ❤
@juanlizarazog Thank you! Source code: https://github.com/juanlizarazo/image-lazy-load-demos Slides: https://speakerdeck.com/juanlizarazo/lazy-loading-images-with-the-intersection-observer