vanilla-lazyload
Version:
A fast, lightweight script to load images as they enter the viewport. SEO friendly, it supports responsive images (both srcset + sizes and picture) and progressive JPEG
12 lines (8 loc) • 403 B
JavaScript
import { detectWebp } from "./lazyload.webp";
export const runningOnBrowser = typeof window !== "undefined";
export const isBot =
(runningOnBrowser && !("onscroll" in window)) ||
/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);
export const supportsClassList =
runningOnBrowser && "classList" in document.createElement("p");
export const supportsWebp = runningOnBrowser && detectWebp();