Skip to content

Instantly share code, notes, and snippets.

@James-Ansley
Created May 29, 2025 11:16
Show Gist options
  • Save James-Ansley/ae5eeb45aa123e98600a4d0b997c1fb7 to your computer and use it in GitHub Desktop.
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.
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()],
});
#!/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