title: Convert an Image DataUrl to Blob in JavaScript with Webkit Fallback?
body: <p>I have an image represented as data URL. I want this image to be converted into a blob. </p>
  
  <p>I use the following method for this purpose:</p>
  
  <pre><code>function dataURItoBlob(dataURI) {
      // convert base64 to raw binary data held in a string
      var byteString = atob(dataURI.split(',')[1]);
  
      // separate out the mime component
      var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
  
      // write the bytes of the string to an ArrayBuffer
      var arrayBuffer = new ArrayBuffer(byteString.length);
      var _ia = new Uint8Array(arrayBuffer);
      for (var i = 0; i &lt; byteString.length; i++) {
          _ia[i] = byteString.charCodeAt(i);
      }
  
      var dataView = new DataView(arrayBuffer);
      var blob = new Blob([dataView], { type: mimeString });
      return blob;
  }
  </code></pre>
  
  <p>This function is working but as I found here: <a href="http://caniuse.com/#feat=bloburls" rel="nofollow">Blob support</a> the blob sometimes need the webkit prefix to work. I know that for URL I could use the fallback with</p>
  
  <pre><code>var _URL = URL || webkitURL;
  </code></pre>
  
  <p><strong>How do I have to include the webkit prefix version as a fallback for older browsers in my function? Do I have to use BlobBuilder() instead on Blob()?</strong></p>