Skip to content

Instantly share code, notes, and snippets.

@jandre3000
Last active January 10, 2024 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandre3000/b3d1c297f8c661e7586eea79fe72feef to your computer and use it in GitHub Desktop.
Save jandre3000/b3d1c297f8c661e7586eea79fe72feef to your computer and use it in GitHub Desktop.
A bash script that measures the download size of Resource Loader modules using the Vector 2022 skin on mediawiki.
#!/bin/bash
RLModules=(
"skins.vector.user"
"skins.vector.user.styles"
"skins.vector.search"
"skins.vector.styles.legacy"
"skins.vector.styles"
"skins.vector.icons.js"
"skins.vector.icons"
"skins.vector.es6"
"skins.vector.js"
"skins.vector.legacy.js"
"skins.vector.zebra.styles" )
prodURL="https://en.wikipedia.org/w/load.php?lang=en&only=styles&skin=vector-2022&modules="
betaURL="https://en.wikipedia.beta.wmflabs.org/w/load.php?lang=en&only=styles&skin=vector-2022&modules="
localURL="http://localhost:8080/w/load.php?lang=en&only=styles&skin=vector-2022&modules="
for resourceLoaderURL in $prodURL $betaURL $localURL
do
echo -e '\n'
echo $resourceLoaderURL
echo '|--------------------------------|-----------|-----------|';
echo '| module name | size (kb) | gzip (kb) |';
echo '|--------------------------------|-----------|-----------|';
for module in ${RLModules[@]}
do
moduleSize=$(curl $resourceLoaderURL$module -so /dev/null -w '%{size_download}' | awk '{print $1/1024}')
moduleSizeGzip=$(curl $resourceLoaderURL$module -so /dev/null -H 'Accept-Encoding: gzip,deflate' -w '%{size_download}' | awk '{print $1/1024}')
printf "| %-30s | %-9s | %-9s |\n" "$module" "$moduleSize" "$moduleSizeGzip"
done
echo '|--------------------------------|-----------|-----------|';
echo -e '\n'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment