A Deno library for measuring webpage sizes and render times. Get accurate measurements of:
- Raw HTML size
- Rendered page size (after JavaScript execution)
- Network transfer size
- Render time
- 🚀 Simple static method for quick measurements
- ⚙️ Configurable options for detailed control
- 📊 Detailed size metrics and timing
- 🌐 Supports custom user agents
- 🔄 Multiple wait conditions for accurate rendering
- 📝 Optional verbose logging
# Import from JSR
import { WebSize } from "jsr:@varandas/websize";
// Quick single measurement
const result = await WebSize.measure("https://example.com");
console.log(result);
// {
// rawSizeKB: 15.2,
// renderedSizeKB: 25.7,
// renderTimeSeconds: 1.2,
// transferSizeMB: 0.35
// }
const result = await WebSize.measure("https://example.com", {
waitUntil: "networkidle2", // Wait for network to be idle
verbose: true, // Enable detailed logging
userAgent: "Custom Agent", // Set custom user agent
});
// Create a reusable instance
const webSize = new WebSize({
verbose: true,
waitUntil: "load",
});
// Measure multiple sites
const sites = ["https://deno.land", "https://example.com"];
for (const site of sites) {
const result = await webSize.calculatePageSize(site);
console.log(`${site}: ${result.renderedSizeKB}KB`);
}
Option | Type | Default | Description |
---|---|---|---|
userAgent |
string |
Chrome/122... | Browser user agent string |
waitUntil |
WaitUntil |
networkidle2 |
Page load condition |
verbose |
boolean |
false |
Enable console logging |
load
: Wait for load eventnetworkidle0
: No network connections for 500msnetworkidle2
: ≤ 2 network connections for 500msnone
: Don't wait
interface PageSizeResult {
rawSizeKB: number; // Size of raw HTML
renderedSizeKB: number; // Size after JavaScript
renderTimeSeconds: number; // Processing time
transferSizeMB: number; // Network transfer size
}
# Run tests
deno task test
# Run example
deno task example
# Type check
deno task check
WebSize uses Astral as its headless browser engine to:
- Fetch raw HTML content
- Execute JavaScript
- Measure rendered page size
- Track network transfers
MIT License - © André Varandas
Found a bug? Open an issue