TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/1TSnakers/ProgressiveImageLoader/llms.txt
Use this file to discover all available pages before exploring further.
ProgressiveImageLoader constructor accepts a single configuration object and immediately begins loading images into the specified container, starting with the lowest-quality image and swapping in higher-quality versions as they finish downloading. It is written in pure vanilla JavaScript with zero dependencies and works in any modern browser without a build step.
Including the Library
Before instantiating the loader, add the script to your HTML page. Place the<script> tag before any code that references ProgressiveImageLoader:
Constructor Signature
Parameters
The constructor takes a single plain object. All fields are listed below.The DOM element into which the progressive image will be rendered. The loader appends an
<img> element as a child of this container and replaces its src each time a higher-quality image finishes loading.An array of image path strings ordered from least to most quality. The first entry is displayed immediately while subsequent images are fetched in the background. Every string in the array should be a valid URL or a path resolvable by the browser relative to the HTML document.
The array must run from worst to best quality. If you are using the
image_ruiner.py companion script, the generated image_list.js file already exports images in the correct order (most degraded first, original last).Display width in pixels applied directly to the
width attribute of the rendered <img> element. When omitted, no explicit width is set and the image renders at its natural size (or whatever your CSS dictates).Display height in pixels applied directly to the
height attribute of the rendered <img> element. When omitted, no explicit height is set. You can specify width alone and let the browser maintain the aspect ratio.Duration in milliseconds for the CSS fade transition that plays each time the loader swaps in a higher-quality image. A value of
500 produces a gentle half-second crossfade; a value of 0 makes transitions instant.When
true, a unique query parameter is appended to each image URL before it is requested, preventing the browser from serving a cached version. This is particularly useful during development when you are regenerating images frequently and want to guarantee the freshest version is always fetched.Full Usage Example
The following snippet mirrors the usage shown in the project demo page. It imports a pre-generated image list from the companion script and passes it straight to the loader:Return Value
ProgressiveImageLoader does not return a meaningful value. The constructor kicks off the image-loading sequence as a side effect; you do not need to hold a reference to the returned instance.
Browser Compatibility
Because the library is written in pure vanilla JavaScript with no dependencies and no transpilation required, it runs in any modern browser that supports standard DOM APIs. No polyfills, bundlers, or framework integrations are needed — a plain<script> tag is all it takes.
The library does make use of ES module
import syntax in the demo (for consuming image_list.js). If your project does not use modules, you can define the images array inline rather than importing it from an external file.