Skip to content

Commit

Permalink
doc: add notes on lazy load
Browse files Browse the repository at this point in the history
  • Loading branch information
twhite313 committed Jan 15, 2025
1 parent 0346214 commit 46aee51
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eds/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export function createAutoplayedVideo(sourceSrc, posterSrc = '') {
type: 'video/mp4',
muted: '',
},

/* add source element with data-src attribute to lazy load the video */
source({ 'data-src': sourceSrc }),
);

Expand All @@ -232,6 +234,7 @@ export function createAutoplayedVideo(sourceSrc, posterSrc = '') {
* IntersectionObserver to play or pause a video element based on its visibility.
* The video element will be played when the intersection ratio exceeds 0.8.
* Otherwise, the video element will pause.
* lazy loads the video source when the video is in view
*/
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
Expand Down

0 comments on commit 46aee51

Please sign in to comment.