mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Add Export APIs & Optimization Checks (Phases 14-15)
Features Added: - HAR file export endpoint (/api/export/:testId/har) - CSV metrics export endpoint (/api/export/:testId/csv) - Optimization checker analyzing 8 categories: * Image optimization * Text compression (gzip/brotli) * Cache policies * Render-blocking resources * Unused JavaScript * Unused CSS * HTTP/2 adoption * Code minification - Frontend optimization checklist with color-coded warnings - Export buttons integrated into results UI Technical Implementation: - Created lib/optimization-checker.js with Lighthouse audit analysis - Added optimization score calculation (0-100%) - Potential time savings displayed for each check - Export buttons wired to download endpoints - Optimization data saved alongside each test result
This commit is contained in:
21
main.js
21
main.js
@@ -122,6 +122,14 @@ function displayResults(data) {
|
||||
if (typeof renderContentBreakdown === 'function') {
|
||||
renderContentBreakdown(data.id);
|
||||
}
|
||||
|
||||
// Load and display optimizations
|
||||
loadOptimizations(data.id);
|
||||
|
||||
// Wire export buttons
|
||||
document.getElementById('export-buttons').style.display = 'block';
|
||||
document.getElementById('export-har').href = `/api/export/${data.id}/har`;
|
||||
document.getElementById('export-csv').href = `/api/export/${data.id}/csv`;
|
||||
|
||||
resultsArea.classList.add('visible');
|
||||
|
||||
@@ -238,9 +246,18 @@ function getUserUuid() {
|
||||
let uuid = localStorage.getItem('user_uuid');
|
||||
if (!uuid) {
|
||||
uuid = crypto.randomUUID();
|
||||
localStorage.setItem('user_uuid', uuid);
|
||||
});
|
||||
|
||||
if (data.checks.length === 0) {
|
||||
html = '<p style="text-align: center; color: var(--color-text-secondary);">✅ All optimization checks passed!</p>';
|
||||
}
|
||||
|
||||
itemsEl.innerHTML = html;
|
||||
container.style.display = 'block';
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to load optimizations:', error);
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
// Initialization
|
||||
|
||||
Reference in New Issue
Block a user