download
Trigger client-side file downloads from JavaScript using strings, Blobs, data URLs, or typed arrays, with no server round trip required.
Repository Health
Technical Analysis
download (published to npm as downloadjs) is a single-function browser library that saves data to the user’s local filesystem entirely from client-side JavaScript. Call download(data, fileName, mimeType) with a URL, plain string, Blob, typed array, or base64/URI-encoded data URL, and it normalizes the input into a Blob and drives the browser’s native save dialog — no backend endpoint or Content-Disposition header needed.
Under the hood it picks the best available mechanism for the current browser: the HTML5 a[download] attribute where supported, navigator.msSaveBlob for older IE, a popup/confirm() fallback for Safari, and a hidden iframe for legacy engines that support neither. It ships as a UMD module, so it works equally as a CommonJS require, an AMD module, or a plain <script> global, and it has zero runtime dependencies.
What You Get
- A single
download(data, fileName, mimeType)function that accepts five different input shapes without requiring the caller to branch on type - Automatic browser-capability detection that picks
a[download],msSaveBlob, a Safari popup fallback, or a hidden iframe as needed - UMD packaging that works as a CommonJS require, an AMD module, or a global
<script>include - Built-in handling for large (>2MB) data URLs by converting them to Blobs instead of holding them as strings
- A minified
download.min.jsbuild shipped directly in the package for CDN/script-tag use
Common Use Cases
- Exporting client-generated reports, CSVs, or JSON as downloadable files without hitting a server endpoint
- Offering a ‘Save as’ action for canvas/image data or ajax response blobs
- Downloading a same-origin file (e.g.
/robots.txtor an image) via a single URL argument - Wiring an ajax success callback directly to a download via
download.bind(true, mimeType, fileName)
Under The Hood
Architecture
The entire library is one exported UMD function (download.js), a monolith by design given its narrow scope: it normalizes the incoming data argument (a same-origin URL, plain string, data URL, Blob, or typed array) into a Blob, then delegates to an internal saver() closure that branches on browser capability — the HTML5 a[download] attribute, navigator.msSaveBlob for older IE, a window.open/confirm() fallback for Safari, or a hidden iframe for legacy engines lacking both. A nested dataUrlToBlob() helper decodes base64 or URI-encoded data URL payloads into a Uint8Array for the Blob constructor. There’s no dependency injection or external state; the whole data flow is a synchronous input-transform followed by a browser-specific save trigger, and the saver fallback chain is the one abstraction any behavior change would have to touch.
Tech Stack
Zero runtime dependencies — pure vanilla JavaScript targeting browser globals (window, Blob, XMLHttpRequest, FileReader, navigator.msSaveBlob) wrapped in a UMD shim supporting AMD (RequireJS), CommonJS (module.exports), and direct global-script consumption. The repo ships a pre-minified download.min.js alongside the source with no visible bundler config or lockfile, and is distributed through both npm (as downloadjs) and Bower, with mirrors on cdnjs and unpkg for <script>-tag use.
Code Quality
No test directory, test framework, or CI workflow is present in the repository; correctness appears to rely on the manually-linked live demo pages referenced throughout the README rather than an automated suite. Error handling is minimal — a try/catch around self.btoa() falls back to encodeURIComponent, but most browser-capability failures (like a blocked Safari popup) surface through confirm() prompts rather than thrown or returned errors. Variable naming favors minimal-size minification-friendly names (a, b, mx, f) over readability, and there’s no TypeScript, JSDoc typing, or linter/formatter configuration in the repo.
API Design
The public surface is a single call, download(data, fileName, mimeType), that accepts five different input shapes (URL, string, data URL, Blob, typed array) without requiring the caller to branch on type first, which is the library’s main ergonomic strength. The README is unusually thorough for a project this small — it documents every parameter and links a live demo for each input type plus a compatibility/FAQ section — but no TypeScript type definitions ship with the package or are referenced on DefinitelyTyped, so consumers get no editor autocomplete for the function signature.
Used by 7 apps in this directory
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Budibase
Low Code Platforms · No Code Platforms
Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.
Bytebase
Devops
An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.
ClearFlask
Product Management · Community
Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.
evidence
Analytics · Data Engineering
Turn SQL queries and markdown files into polished, interactive data apps and business intelligence reports — no drag-and-drop, no GUI, just code.
ILLA Builder
Developer Tools · Low Code Platforms · No Code Platforms
Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.
LibreChat
Developer Tools · AI Assistants
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.