Skip to content

Commit 9cb474e

Browse files
committed
adjust cdn example
1 parent f3b092b commit 9cb474e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ const compressedImage = await compressFile(file);
6060
<html lang="en">
6161
<head>
6262
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/simple-image-compressor.js"></script>
63-
<script defer>
64-
const fileInput = document.getElementById('file-input');
65-
const file = fileInput.files[0];
66-
const options = {
67-
quality: 0.9,
68-
type: 'image/jpeg',
69-
}
70-
const compressedImage = await imageCompressor.compressImage(file, options);
71-
// do something with that image...
63+
<script>
64+
window.onload = () => {
65+
const fileInput = document.getElementById('file-input');
66+
fileInput.addEventListener('change', async () => {
67+
const file = fileInput.files[0];
68+
const options = {
69+
quality: 0.9,
70+
type: imageCompressor.imageTypes.WEBP,
71+
};
72+
const compressedImage = await imageCompressor.compressImage(file, options);
73+
// do something with the compressed image
74+
});
75+
};
7276
</script>
7377
</head>
7478

0 commit comments

Comments
 (0)