
          var newImage = new Image();

          newImage.src = URL.createObjectURL(result);
          newImage.alt = 'Compressed image';
          output.appendChild(newImage);
        }).catch((err) => {
          console.log('Compress error');
          window.alert(err.message);
        }).finally(() => {
          console.log('Compress complete');
        });
      };

      xhr.open('GET', image.src);
      xhr.responseType = 'blob';
      xhr.send();
    });
  </script>
</body>
</html>
