analytics/tracker/report-sizes.js

29 lines
732 B
JavaScript
Raw Normal View History

2024-10-28 12:59:16 +03:00
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)