Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (52 sloc) 1.95 KB


This jQuery plugin uses the data: URI to download the DOM of arbitrary elements into files. One file will be downloaded for each selected element. Since the DOM is captured, any javascript-generated content will be included in the download.

See it in action.


failCallback: (Optional) The browser may not support the data: URI. If this is the case, this function will be called once with the text of each element not downloaded.


There is also a utility function you can use to check whether the browser supports the data URI. This will return true if there is support, and false otherwise.



This will download into a browser-named file the contents of the current page view:


This would download every svg on the page into a separate file:


This takes advantage of failCallback in case the browser doesn't support the data: uri.

    var failCallback = function(text) {
      alert("Could not download " + text);


It is not possible to specify a name for the downloaded file. If at some point arbitrary headers are added to the data: uri spec, this would be possible using Content-Disposition with filename.

There was some discussion about this on the, but it has not led to any change in the spec.

Any browsers with limited data: uri support will not work, either. The failCallback is your friend.


Fork it from

CDN it at