Download.js is a client-side JavaScript library, currently at version 1.4.7, designed to programmatically trigger file downloads within the user's browser without requiring server interaction. It provides a single `download()` function that can accept various data types, including URLs, plain strings, Blobs, Typed Arrays, and dataURLs, abstracting the complexities of browser-specific download mechanisms. The library aims to set the filename and MIME type via browser capabilities, behaving similarly to a server's `Content-Disposition` header. While the release cadence is infrequent, the library remains active, offering a lightweight solution for in-browser file generation and download. Its key differentiators lie in its broad data input flexibility and wide browser compatibility, albeit with notable limitations on older browsers and devices lacking local file system access or specific web APIs like `Blob` or `window.URL`.
npm install downloadjsVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of the global `download` function to save various types of client-side generated files like text, HTML, and SVG.
Inform users about device limitations or provide alternative file handling mechanisms for incompatible platforms.
Be aware of these limitations for users on very old browsers. The library provides a best-effort approach.
Check browser compatibility for Blob API if using Blob or TypedArray inputs. Consider polyfills or fallback mechanisms for older browsers.
For AJAX downloads, use an explicit `XMLHttpRequest` with `responseType='blob'` and manually call `download(e.target.response, ...)` in the `onload` handler.
Test thoroughly on target Android devices and browsers, especially for older OS versions.
This is often a fundamental device limitation. The library cannot circumvent the absence of a file system. Inform users of this limitation.
Update browser if possible, or accept that custom filenames may not be honored on very old systems. The content type should still be correct.
Check the browser's compatibility for the Blob API. For environments lacking Blob support, you might need to convert data to a dataURL string as a fallback, although this has size limitations.
No dependency data recorded yet.