Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think there are any guarantees given about the memory usage of data URLs. If you can figure out a way to get them to behave in one browser, it guarantees little if not nothing about other browsers or versions.</p> <p>If you put your image data into a blob and then create a blob URL, you can then deallocate that data.</p> <p>Here's an example which turns a data URI into a blob URL; you may need to change / drop the <code>webkit-</code> &amp; <code>WebKit-</code> prefixes on browsers other than Chrome and possibly future versions of Chrome.</p> <pre><code>var parts = dataURL.match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/); //assume base64 encoding var binStr = atob(parts[3]); //might be able to replace the following lines with just // var view = new Uint8Array(binStr); //haven't tested. //convert to binary in ArrayBuffer var buf = new ArrayBuffer(binStr.length); var view = new Uint8Array(buf); for(var i = 0; i &lt; view.length; i++) view[i] = binStr.charCodeAt(i); //end of the possibly unnecessary lines var builder = new WebKitBlobBuilder(); builder.append(buf); //create blob with mime type, create URL for it var URL = webkitURL.createObjectURL(builder.getBlob(parts[1])) return URL; </code></pre> <p>Deallocating is as easy as :</p> <pre><code>webkitURL.revokeObjectURL(URL); </code></pre> <p>And you can use your blob URL as your <code>img</code>'s <code>src</code>.</p> <p>Unfortunately, blob URLs do not appear to be supported in IE prior to v10.</p> <h1>API reference:</h1> <p><a href="http://www.w3.org/TR/FileAPI/#dfn-createObjectURL" rel="nofollow">http://www.w3.org/TR/FileAPI/#dfn-createObjectURL</a></p> <p><a href="http://www.w3.org/TR/FileAPI/#dfn-revokeObjectURL" rel="nofollow">http://www.w3.org/TR/FileAPI/#dfn-revokeObjectURL</a></p> <h1>Compatibility reference:</h1> <p><a href="http://caniuse.com/#search=blob%20url" rel="nofollow">http://caniuse.com/#search=blob%20url</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload