Lazy loading JavaScript using IntersectionObserver

Jonathan Neal dissects the Islands Architecture approach behind Astro. During the presentation, Fred demonstrates dynamically loading JS using “Islands Architecture”,a strategy where small HTML placeholders are progressively upgraded with dynamic or interactive content as-needed. The demonstration involves waiting on the viewport visibility of a div placeholder before loading some JS. Using an IIFE an IntersectionObserver …


This content originally appeared on Bram.us and was authored by Bramus!

Jonathan Neal dissects the Islands Architecture approach behind Astro.

During the presentation, Fred demonstrates dynamically loading JS using “Islands Architecture”,a strategy where small HTML placeholders are progressively upgraded with dynamic or interactive content as-needed.

The demonstration involves waiting on the viewport visibility of a div placeholder before loading some JS.

Using an IIFE an IntersectionObserver is attached to keep an eye on a preceding a DOM Node. Once in view it’ll disconnect the IntersectionObserver and run whatever JS you want it to run (such as loading and rendering a React App).

Lazy loading JS by visibility →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2021-05-10T21:21:02+00:00) Lazy loading JavaScript using IntersectionObserver. Retrieved from https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/

MLA
" » Lazy loading JavaScript using IntersectionObserver." Bramus! | Sciencx - Monday May 10, 2021, https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/
HARVARD
Bramus! | Sciencx Monday May 10, 2021 » Lazy loading JavaScript using IntersectionObserver., viewed ,<https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/>
VANCOUVER
Bramus! | Sciencx - » Lazy loading JavaScript using IntersectionObserver. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/
CHICAGO
" » Lazy loading JavaScript using IntersectionObserver." Bramus! | Sciencx - Accessed . https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/
IEEE
" » Lazy loading JavaScript using IntersectionObserver." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/. [Accessed: ]
rf:citation
» Lazy loading JavaScript using IntersectionObserver | Bramus! | Sciencx | https://www.scien.cx/2021/05/10/lazy-loading-javascript-using-intersectionobserver/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.