A lazy image loader that enforces progressive enhancement and valid HTML by loading images from noscript tags.
Lazy Progressive Enhancement is a minimal JavaScript function for lazy-loading images that enforces progressive enhancement and valid HTML. It solves the problem of lazy loaders that promote invalid HTML by omitting src attributes or fail without JavaScript, ensuring images are always accessible. It works by extracting images from `<noscript>` tags, preserving attributes and providing fallbacks.
Frontend developers who prioritize web standards, accessibility, and valid HTML in their projects, especially those building performance-sensitive websites that need lazy loading without compromising user experience.
Developers choose it because it’s dependency-free, enforces valid HTML, and guarantees compatibility for users without JavaScript, unlike many lazy loaders that break standards. Its simplicity as a single function makes it easy to integrate and customize.
A lazy image loader designed to enforce progressive enhancement and valid HTML.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses <noscript> fallbacks to ensure images always have valid src attributes, avoiding the invalid HTML issues common in other lazy loaders. This guarantees compatibility for users without JavaScript.
Written in pure JavaScript with no external libraries, making it lightweight and easy to integrate without bloating your project. The README emphasizes it's 'not a framework, not a library, just a function.'
Supports loading specific images via CSS selectors, NodeLists, or single elements, allowing precise control over which images are lazy-loaded. The README provides examples for targeting with selectors like '#this-one'.
Compatible with responsive srcset images and iframes, ensuring modern web standards are maintained. The README explicitly lists 'Works with responsive `srcset` images' as a benefit.
Allows attaching custom functions to run after each image loads, enabling animations or other post-load actions. The 'onload Function' section shows how to add classes like 'loaded' to images.
Uses a general scroll-based solution that may be less performant than intersection observers, and the README admits 'creating your own scroll-based loading functionality may be more performant.' It also notes it will update to intersection observers only when standardized.
Requires wrapping every image in <noscript> tags, which adds boilerplate HTML and can be tedious for large numbers of images, unlike lazy loaders that use data attributes for a cleaner markup.
The README does not mention built-in error handling for failed image loads, leaving developers to implement their own solutions, which could be a drawback for reliability in production.
As a minimal function, it lacks the plugins, community tools, or extensive documentation found in larger libraries, making it harder to extend or troubleshoot in complex scenarios.