analytics/tracker/report-sizes.js
2024-10-28 09:59:16 +00:00

29 lines
732 B
JavaScript

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const PrivTrackerDir = '../priv/tracker/js/';
const toReport = [
'plausible.js',
'plausible.pageleave.js',
'plausible.manual.pageleave.js',
'plausible.hash.pageleave.js'
];
const results = [];
toReport.forEach((filename) => {
const filePath = path.join(PrivTrackerDir, filename);
if (fs.statSync(filePath).isFile()) {
results.push({
'Filename': filename,
'Real Size (Bytes)': fs.statSync(filePath).size,
'Gzipped Size (Bytes)': execSync(`gzip -c -9 "${filePath}"`).length,
'Brotli Size (Bytes)': execSync(`brotli -c -q 11 "${filePath}"`).length
});
}
});
console.table(results)