Build a mobile parity sentinel: render diffs, blocked resources, and parity score.
- User
Build a mobile parity sentinel: render diffs, blocked resources, and parity score.
Assistant
Build a mobile parity sentinel: render diffs, blocked resources, and parity score.
The user wants me to build a "Mobile Parity Sentinel" - a tool that compares desktop and mobile versions of a website to check for parity. This should show:
This is a developer tool/dashboard concept. I'll create a visually striking, interactive single-page app that simulates this functionality.
Key features to implement:
Design approach:
Let me build this out with:
A developer tool dashboard for analyzing mobile-desktop parity, visualizing render differences, blocked resources, and calculating a parity score.
Design approach:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mobile Parity Sentinel</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@400;500;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0e14;
--bg-elevated: #111820;
--bg-card: #151d28;
--fg: #e6edf3;
--fg-muted: #6b7d93;
--accent: #00d9ff;
--accent-dim: rgba(0, 217, 255, 0.15);
--danger: #ff4757;
--warning: #ffa502;
--success: #2ed573;
--border: #1e2a3a;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.font-mono {
font-family: 'JetBrains Mono', monospace;
}
/* Scan line effect */
.scan-line {
position: relative;
overflow: hidden;
}
.scan-line::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, transparent, var(--accent), transparent);
animation: scan 2s ease-in-out infinite;
opacity: 0;
}
.scanning .scan-line::after {
opacity: 1;
}
@keyframes scan {
0%, 100% { top: 0; opacity: 0; }
10% { opacity: 1; }
90% { opacity: 1; }
100% { top: calc(100% - 4px); opacity: 0; }
}
/* Grid background */
.grid-bg {
background-image:
linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
background-size: 40px 40px;
}
/* Glow effects */
.glow-accent {
box-shadow: 0 0 20px rgba(0, 217, 255, 0.3), 0 0 40px rgba(0, 217, 255, 0.1);
}
.glow-danger {
box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}
/* Score gauge */
.score-ring {
transform: rotate(-90deg);
}
.score-ring circle {
fill: none;
stroke-width: 8;
stroke-linecap: round;
}
.score-ring .bg-ring {
stroke: var(--border);
}
.score-ring .progress-ring {
stroke: var(--accent);
stroke-dasharray: 283;
stroke-dashoffset: 283;
transition: stroke-dashoffset 1.5s ease-out, stroke 0.3s;
}
/* Diff visualization */
.diff-block {
position: relative;
padding: 12px 16px;
border-radius: 6px;
font-family: 'JetBrains Mono', monospace;
font-size: 13px;
line-height: 1.6;
border-left: 3px solid;
}
.diff-removed {
background: rgba(255, 71, 87, 0.1);
border-color: var(--danger);
}
.diff-added {
background: rgba(46, 213, 115, 0.1);
border-color: var(--success);
}
.diff-modified {
background: rgba(255, 165, 2, 0.1);
border-color: var(--warning);
}
/* Resource item */
.resource-item {
transition: all 0.2s ease;
}
.resource-item:hover {
background: var(--bg-elevated);
transform: translateX(4px);
}
/* Button styles */
.btn-primary {
background: var(--accent);
color: var(--bg);
font-weight: 600;
padding: 12px 24px;
border-radius: 8px;
border: none;
cursor: pointer;
transition: all 0.2s ease;
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(0, 217, 255, 0.3);
}
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Input styles */
.input-field {
background: var(--bg-elevated);
border: 2px solid var(--border);
color: var(--fg);
padding: 14px 18px;
border-radius: 8px;
font-size: 15px;
transition: all 0.2s ease;
width: 100%;
}
.input-field:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 4px var(--accent-dim);
}
.input-field::placeholder {
color: var(--fg-muted);
}
/* Tab styles */
.tab-btn {
padding: 10px 20px;
background: transparent;
border: none;
color: var(--fg-muted);
font-weight: 500;
cursor: pointer;
position: relative;
transition: color 0.2s;
}
.tab-btn:hover {
color: var(--fg);
}
.tab-btn.active {
color: var(--accent);
}
.tab-btn.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
background: var(--accent);
}
/* Stagger animation */
.stagger-item {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.4s ease, transform 0.4s ease;
}
.stagger-item.visible {
opacity: 1;
transform: translateY(0);
}
/* Pulse animation */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.pulse {
animation: pulse 2s ease-in-out infinite;
}
/* Mobile preview frames */
.device-frame {
background: var(--bg-card);
border: 2px solid var(--border);
border-radius: 24px;
padding: 12px;
position: relative;
}
.device-frame::before {
content: '';
position: absolute;
top: 8px;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 6px;
background: var(--border);
border-radius: 3px;
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-elevated);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--fg-muted);
}
</style>
</head>
<body class="grid-bg">
<!-- Header -->
<header class="border-b border-[var(--border)] bg-[var(--bg-elevated)]/80 backdrop-blur-sm sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 py-4 flex items-center justify-between">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-[var(--accent)] flex items-center justify-center">
<svg class="w-6 h-6 text-[var(--bg)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
</svg>
</div>
<div>
<h1 class="text-lg font-bold tracking-tight">Mobile Parity Sentinel</h1>
<p class="text-xs text-[var(--fg-muted)] font-mono">v2.4.0</p>
</div>
</div>
<div class="flex items-center gap-4">
<span class="hidden sm:flex items-center gap-2 text-sm text-[var(--fg-muted)]">
<span class="w-2 h-2 rounded-full bg-[var(--success)] pulse"></span>
System Online
</span>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 sm:px-6 py-8">
<!-- Input Section -->
<section class="mb-8 stagger-item" id="inputSection">
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-6">
<div class="flex flex-col sm:flex-row gap-4">
<div class="flex-1">
<label for="urlInput" class="block text-sm font-medium mb-2 text-[var(--fg-muted)]">Target URL</label>
<input
type="url"
id="urlInput"
class="input-field font-mono"
placeholder="https://example.com"
value="https://shop.techstore.io"
>
</div>
<div class="flex items-end">
<button id="analyzeBtn" class="btn-primary flex items-center gap-2 w-full sm:w-auto justify-center">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
<span id="btnText">Analyze</span>
</button>
</div>
</div>
<div id="progressContainer" class="hidden mt-4">
<div class="flex items-center justify-between text-sm mb-2">
<span class="text-[var(--fg-muted)]" id="progressText">Initializing scan...</span>
<span class="font-mono text-[var(--accent)]" id="progressPercent">0%</span>
</div>
<div class="h-2 bg-[var(--bg)] rounded-full overflow-hidden">
<div id="progressBar" class="h-full bg-[var(--accent)] rounded-full transition-all duration-300" style="width: 0%"></div>
</div>
</div>
</div>
</section>
<!-- Results Section -->
<section id="resultsSection" class="hidden">
<!-- Score Overview -->
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6 mb-8">
<div class="lg:col-span-1 bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-6 stagger-item">
<h3 class="text-sm font-medium text-[var(--fg-muted)] mb-4">Parity Score</h3>
<div class="flex items-center justify-center">
<div class="relative">
<svg class="score-ring w-32 h-32" viewBox="0 0 100 100">
<circle class="bg-ring" cx="50" cy="50" r="45"/>
<circle class="progress-ring" id="scoreRing" cx="50" cy="50" r="45"/>
</svg>
<div class="absolute inset-0 flex items-center justify-center flex-col">
<span class="text-3xl font-bold" id="scoreValue">--</span>
<span class="text-xs text-[var(--fg-muted)]">/ 100</span>
</div>
</div>
</div>
<div class="mt-4 text-center">
<span id="scoreLabel" class="text-sm font-medium px-3 py-1 rounded-full bg-[var(--accent-dim)] text-[var(--accent)]">Analyzing...</span>
</div>
</div>
<div class="lg:col-span-3 grid grid-cols-1 sm:grid-cols-3 gap-4">
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5 stagger-item">
<div class="flex items-center justify-between mb-3">
<span class="text-sm text-[var(--fg-muted)]">Render Diffs</span>
<svg class="w-5 h-5 text-[var(--warning)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
</div>
<p class="text-2xl font-bold" id="diffCount">--</p>
<p class="text-xs text-[var(--fg-muted)] mt-1">Differences detected</p>
</div>
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5 stagger-item">
<div class="flex items-center justify-between mb-3">
<span class="text-sm text-[var(--fg-muted)]">Blocked Resources</span>
<svg class="w-5 h-5 text-[var(--danger)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
</svg>
</div>
<p class="text-2xl font-bold" id="blockedCount">--</p>
<p class="text-xs text-[var(--fg-muted)] mt-1">Resources blocked</p>
</div>
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5 stagger-item">
<div class="flex items-center justify-between mb-3">
<span class="text-sm text-[var(--fg-muted)]">Load Time Delta</span>
<svg class="w-5 h-5 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<p class="text-2xl font-bold" id="loadDelta">--</p>
<p class="text-xs text-[var(--fg-muted)] mt-1">Mobile vs Desktop</p>
</div>
</div>
</div>
<!-- Tabs -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] overflow-hidden stagger-item">
<div class="border-b border-[var(--border)] flex">
<button class="tab-btn active" data-tab="diffs">Render Diffs</button>
<button class="tab-btn" data-tab="blocked">Blocked Resources</button>
<button class="tab-btn" data-tab="preview">Preview</button>
</div>
<!-- Render Diffs Tab -->
<div id="diffsTab" class="tab-content p-6">
<div class="flex items-center justify-between mb-6">
<div class="flex items-center gap-3">
<span class="flex items-center gap-2 text-sm">
<span class="w-3 h-3 rounded bg-[var(--danger)]"></span> Removed
</span>
<span class="flex items-center gap-2 text-sm">
<span class="w-3 h-3 rounded bg-[var(--success)]"></span> Added
</span>
<span class="flex items-center gap-2 text-sm">
<span class="w-3 h-3 rounded bg-[var(--warning)]"></span> Modified
</span>
</div>
</div>
<div id="diffsList" class="space-y-4 max-h-[500px] overflow-y-auto pr-2">
<!-- Diffs will be injected here -->
</div>
</div>
<!-- Blocked Resources Tab -->
<div id="blockedTab" class="tab-content hidden p-6">
<div class="mb-4">
<div class="flex items-center gap-4 text-sm text-[var(--fg-muted)] mb-4">
<span>Showing <strong class="text-[var(--fg)]" id="blockedShown">0</strong> blocked resources</span>
</div>
</div>
<div id="blockedList" class="space-y-2 max-h-[500px] overflow-y-auto pr-2">
<!-- Blocked resources will be injected here -->
</div>
</div>
<!-- Preview Tab -->
<div id="previewTab" class="tab-content hidden p-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h4 class="text-sm font-medium text-[var(--fg-muted)] mb-3 flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
Desktop Render
</h4>
<div class="bg-[var(--bg)] rounded-lg border border-[var(--border)] aspect-video relative overflow-hidden scan-line">
<div id="desktopPreview" class="absolute inset-0 p-4">
<!-- Desktop preview content -->
</div>
</div>
</div>
<div>
<h4 class="text-sm font-medium text-[var(--fg-muted)] mb-3 flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"/>
</svg>
Mobile Render
</h4>
<div class="device-frame aspect-[9/16] max-w-[280px] mx-auto relative overflow-hidden scan-line">
<div id="mobilePreview" class="absolute inset-0 pt-6 p-3">
<!-- Mobile preview content -->
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<script>
// Dataset - simulated analysis results
const analysisData = {
renderDiffs: [
{
type: 'removed',
selector: '.hero-video',
desktop: '<video autoplay loop src="hero.mp4">',
mobile: '[Element removed]',
impact: 'high',
description: 'Autoplay video removed on mobile to reduce data usage'
},
{
type: 'modified',
selector: '.product-grid',
desktop: 'grid-template-columns: 4',
mobile: 'grid-template-columns: 2',
impact: 'medium',
description: 'Product grid reduced from 4 to 2 columns'
},
{
type: 'added',
selector: '.mobile-nav-toggle',
desktop: '[Not present]',
mobile: '<button class="mobile-nav-toggle">',
impact: 'low',
description: 'Mobile navigation toggle button added'
},
{
type: 'removed',
selector: '.sidebar-filters',
desktop: '<aside class="sidebar-filters">...</aside>',
mobile: '[Element removed]',
impact: 'high',
description: 'Sidebar filters completely removed on mobile view'
},
{
type: 'modified',
selector: '.header-promo',
desktop: 'font-size: 14px; padding: 12px',
mobile: 'font-size: 11px; padding: 8px',
impact: 'low',
description: 'Promotional banner styling adjusted for mobile'
},
{
type: 'modified',
selector: '.product-card__image',
desktop: 'height: 280px',
mobile: 'height: 180px',
impact: 'medium',
description: 'Product card image height reduced by 35%'
}
],
blockedResources: [
{
url: 'https://cdn.shopify.com/s/files/1/0234/.../hero-background.webp',
type: 'image',
reason: 'Blocked by lazy-load directive',
size: '2.4 MB',
impact: 'high'
},
{
url: 'https://www.googletagmanager.com/gtm.js?id=GTM-XXXXX',
type: 'script',
reason: 'Blocked by CSP on mobile network',
size: '89 KB',
impact: 'medium'
},
{
url: 'https://connect.facebook.net/en_US/fbevents.js',
type: 'script',
reason: 'Deferred until user interaction',
size: '156 KB',
impact: 'low'
},
{
url: 'https://cdn.jsdelivr.net/npm/analytics@2.0.0/dist/full.js',
type: 'script',
reason: 'Blocked by mobile data saver',
size: '234 KB',
impact: 'medium'
},
{
url: 'https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700',
type: 'font',
reason: 'Unused font blocked by optimizer',
size: '45 KB',
impact: 'low'
},
{
url: 'https://i.ytimg.com/vi/abc123/maxresdefault.jpg',
type: 'image',
reason: 'YouTube thumbnail blocked by lazy-load',
size: '180 KB',
impact: 'medium'
}
],
parityScore: 73,
loadTimeDelta: '+1.8s'
};
// DOM Elements
const urlInput = document.getElementById('urlInput');
const analyzeBtn = document.getElementById('analyzeBtn');
const btnText = document.getElementById('btnText');
const progressContainer = document.getElementById('progressContainer');
const progressBar = document.getElementById('progressBar');
const progressText = document.getElementById('progressText');
const progressPercent = document.getElementById('progressPercent');
const resultsSection = document.getElementById('resultsSection');
const scoreRing = document.getElementById('scoreRing');
const scoreValue = document.getElementById('scoreValue');
const scoreLabel = document.getElementById('scoreLabel');
const diffCount = document.getElementById('diffCount');
const blockedCount = document.getElementById('blockedCount');
const loadDelta = document.getElementById('loadDelta');
const diffsList = document.getElementById('diffsList');
const blockedList = document.getElementById('blockedList');
const blockedShown = document.getElementById('blockedShown');
const desktopPreview = document.getElementById('desktopPreview');
const mobilePreview = document.getElementById('mobilePreview');
// State
let isAnalyzing = false;
let currentTab = 'diffs';
// Tab handling
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.addEventListener('click', () => {
const tab = btn.dataset.tab;
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
document.querySelectorAll('.tab-content').forEach(c => c.classList.add('hidden'));
document.getElementById(`${tab}Tab`).classList.remove('hidden');
currentTab = tab;
});
});
// Progress simulation
const progressSteps = [
{ percent: 10, text: 'Fetching desktop snapshot...' },
{ percent: 25, text: 'Fetching mobile snapshot...' },
{ percent: 40, text: 'Analyzing DOM differences...' },
{ percent: 55, text: 'Detecting blocked resources...' },
{ percent: 70, text: 'Calculating parity metrics...' },
{ percent: 85, text: 'Generating visual diff...' },
{ percent: 95, text: 'Compiling report...' },
{ percent: 100, text: 'Analysis complete!' }
];
// Animate score ring
function animateScore(score) {
const circumference = 2 * Math.PI * 45;
const offset = circumference - (score / 100) * circumference;
scoreRing.style.strokeDashoffset = offset;
// Color based on score
let color = 'var(--danger)';
let label = 'Poor';
if (score >= 80) {
color = 'var(--success)';
label = 'Excellent';
} else if (score >= 60) {
color = 'var(--warning)';
label = 'Fair';
} else if (score >= 40) {
color = 'var(--danger)';
label = 'Needs Work';
} else {
label = 'Critical';
}
scoreRing.style.stroke = color;
scoreLabel.textContent = label;
scoreLabel.style.background = color === 'var(--success)' ? 'rgba(46, 213, 115, 0.15)' :
color === 'var(--warning)' ? 'rgba(255, 165, 2, 0.15)' :
'rgba(255, 71, 87, 0.15)';
scoreLabel.style.color = color;
// Animate number
let current = 0;
const increment = score / 30;
const timer = setInterval(() => {
current += increment;
if (current >= score) {
current = score;
clearInterval(timer);
}
scoreValue.textContent = Math.round(current);
}, 30);
}
// Render diffs list
function renderDiffs() {
diffsList.innerHTML = analysisData.renderDiffs.map((diff, i) => `
<div class="diff-block diff-${diff.type}" style="animation-delay: ${i * 100}ms">
<div class="flex items-start justify-between gap-4 mb-2">
<code class="text-xs bg-black/30 px-2 py-1 rounded">${diff.selector}</code>
<span class="text-xs px-2 py-1 rounded ${
diff.impact === 'high' ? 'bg-red-500/20 text-red-400' :
diff.impact === 'medium' ? 'bg-yellow-500/20 text-yellow-400' :
'bg-blue-500/20 text-blue-400'
}">${diff.impact} impact</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-3">
<div>
<span class="text-xs text-[var(--fg-muted)] block mb-1">Desktop</span>
<code class="text-xs break-all">${diff.desktop}</code>
</div>
<div>
<span class="text-xs text-[var(--fg-muted)] block mb-1">Mobile</span>
<code class="text-xs break-all">${diff.mobile}</code>
</div>
</div>
<p class="text-xs text-[var(--fg-muted)] mt-3">${diff.description}</p>
</div>
`).join('');
}
// Render blocked resources
function renderBlockedResources() {
blockedShown.textContent = analysisData.blockedResources.length;
blockedList.innerHTML = analysisData.blockedResources.map((res, i) => `
<div class="resource-item p-4 rounded-lg border border-[var(--border)] cursor-pointer" style="animation-delay: ${i * 50}ms">
<div class="flex items-start justify-between gap-4">
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2 mb-2">
<span class="text-xs px-2 py-0.5 rounded ${
res.type === 'script' ? 'bg-purple-500/20 text-purple-400' :
res.type === 'image' ? 'bg-green-500/20 text-green-400' :
'bg-blue-500/20 text-blue-400'
}">${res.type}</span>
<span class="text-xs text-[var(--fg-muted)]">${res.size}</span>
</div>
<code class="text-xs block truncate text-[var(--fg-muted)]">${res.url}</code>
<p class="text-xs text-[var(--danger)] mt-2">${res.reason}</p>
</div>
<span class="text-xs px-2 py-1 rounded ${
res.impact === 'high' ? 'bg-red-500/20 text-red-400' :
res.impact === 'medium' ? 'bg-yellow-500/20 text-yellow-400' :
'bg-blue-500/20 text-blue-400'
}">${res.impact}</span>
</div>
</div>
`).join('');
}
// Render preview
function renderPreview() {
desktopPreview.innerHTML = `
<div class="w-full h-full bg-[var(--bg-elevated)] rounded-lg overflow-hidden">
<div class="h-8 bg-[var(--border)] flex items-center px-2 gap-1">
<div class="w-2 h-2 rounded-full bg-red-500/50"></div>
<div class="w-2 h-2 rounded-full bg-yellow-500/50"></div>
<div class="w-2 h-2 rounded-full bg-green-500/50"></div>
</div>
<div class="p-2 space-y-2">
<div class="h-3 bg-[var(--accent)]/30 rounded w-1/3"></div>
<div class="h-20 bg-[var(--border)] rounded"></div>
<div class="grid grid-cols-4 gap-1">
${Array(8).fill('<div class="aspect-square bg-[var(--border)] rounded"></div>').join('')}
</div>
<div class="h-8 bg-[var(--accent)]/20 rounded w-1/2"></div>
</div>
</div>
`;
mobilePreview.innerHTML = `
<div class="w-full h-full bg-[var(--bg-elevated)] rounded-lg overflow-hidden">
<div class="p-2 space-y-2">
<div class="flex items-center justify-between">
<div class="h-2 w-4 bg-[var(--border)] rounded"></div>
<div class="h-2 w-4 bg-[var(--accent)]/30 rounded"></div>
</div>
<div class="h-10 bg-[var(--border)] rounded"></div>
<div class="grid grid-cols-2 gap-1">
${Array(4).fill('<div class="aspect-square bg-[var(--border)] rounded"></div>').join('')}
</div>
<div class="h-6 bg-[var(--accent)]/20 rounded"></div>
</div>
</div>
`;
}
// Stagger animation for elements
function animateStagger() {
const items = document.querySelectorAll('.stagger-item');
items.forEach((item, i) => {
setTimeout(() => {
item.classList.add('visible');
}, i * 100);
});
}
// Main analysis function
async function runAnalysis() {
if (isAnalyzing) return;
const url = urlInput.value.trim();
if (!url) {
urlInput.focus();
return;
}
isAnalyzing = true;
analyzeBtn.disabled = true;
btnText.textContent = 'Analyzing...';
progressContainer.classList.remove('hidden');
resultsSection.classList.add('hidden');
// Reset progress
progressBar.style.width = '0%';
// Animate through progress steps
for (const step of progressSteps) {
await new Promise(resolve => setTimeout(resolve, 400 + Math.random() * 300));
progressBar.style.width = `${step.percent}%`;
progressText.textContent = step.text;
progressPercent.textContent = `${step.percent}%`;
}
// Show results
await new Promise(resolve => setTimeout(resolve, 300));
progressContainer.classList.add('hidden');
resultsSection.classList.remove('hidden');
// Update stats
diffCount.textContent = analysisData.renderDiffs.length;
blockedCount.textContent = analysisData.blockedResources.length;
loadDelta.textContent = analysisData.loadTimeDelta;
// Render content
renderDiffs();
renderBlockedResources();
renderPreview();
// Animate score after a short delay
setTimeout(() => {
animateScore(analysisData.parityScore);
}, 500);
// Trigger stagger animations
animateStagger();
// Reset button
isAnalyzing = false;
analyzeBtn.disabled = false;
btnText.textContent = 'Reanalyze';
}
// Event listeners
analyzeBtn.addEventListener('click', runAnalysis);
urlInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
runAnalysis();
}
});
// Initial animation for input section
setTimeout(() => {
document.getElementById('inputSection').classList.add('visible');
}, 100);
</script>
</body>
</html>
Visual Design:
Core Functionality:
Interactions:
Metrics Tracked: