Created
May 29, 2025 11:16
-
-
Save James-Ansley/ae5eeb45aa123e98600a4d0b997c1fb7 to your computer and use it in GitHub Desktop.
Some fun little scripts that list the sizes of minified and gzipped javascript files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {rollup} from "npm:rollup"; | |
import terser from "npm:@rollup/plugin-terser"; | |
const bundle = await rollup({ | |
input: "./src/main.js", | |
}); | |
await bundle.write({ | |
file: "./dist/out.js", | |
format: "cjs", | |
}); | |
await bundle.write({ | |
file: "./dist/out.min.js", | |
format: "cjs", | |
plugins: [terser()], | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
deno run -A rollup.js | |
js="out.js" | |
min="out.min.js" | |
echo "Compiled size: $(wc ./dist/$js -c | cut -d' ' -f1) bytes ($js)" | |
echo "Minified size: $(wc ./dist/$min -c | cut -d' ' -f1) bytes ($min)" | |
echo "Gzipped size: $(gzip ./dist/$min -c | wc -c | cut -d' ' -f1) bytes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment