Skip to content
TheChatArchiveThe Chat Archive
grok-4-0709· xAIHugging Face LMArena Human Preference 140K

Create an astonishing web app in a single HTML+CSS+JS file that will leave me in awe

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-opus-4-20250514’s answer.
  1. User

    Create an astonishing web app in a single HTML+CSS+JS file that will leave me in awe

  2. Assistant
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Astonishing Fireworks Spectacle</title>
        <style>
            body {
                margin: 0;
                overflow: hidden;
                background: #000;
                display: flex;
                justify-content: center;
                align-items: center;
                height: 100vh;
                font-family: Arial, sans-serif;
            }
            canvas {
                display: block;
                background: radial-gradient(circle, #001022, #000);
            }
            #info {
                position: absolute;
                top: 20px;
                left: 50%;
                transform: translateX(-50%);
                color: #fff;
                text-align: center;
                opacity: 0.8;
                pointer-events: none;
            }
            #info h1 {
                margin: 0;
                font-size: 24px;
            }
            #info p {
                margin: 5px 0 0;
                font-size: 16px;
            }
        </style>
    </head>
    <body>
        <canvas id="canvas"></canvas>
        <div id="info">
            <h1>Fireworks Spectacle</h1>
            <p>Click or tap anywhere to launch fireworks! (Multi-touch supported on mobile)</p>
        </div>
        <script>
            const canvas = document.getElementById('canvas');
            const ctx = canvas.getContext('2d');
            
            // Fullscreen canvas
            function resizeCanvas() {
                canvas.width = window.innerWidth;
                canvas.height = window.innerHeight;
            }
            window.addEventListener('resize', resizeCanvas);
            resizeCanvas();
            
            // Firework classes
            class Particle {
                constructor(x, y, vx, vy, color, size, life) {
                    this.x = x;
                    this.y = y;
                    this.vx = vx;
                    this.vy = vy;
                    this.color = color;
                    this.size = size;
                    this.life = life;
                    this.alpha = 1;
                }
                
                update() {
                    this.x += this.vx;
                    this.y += this.vy;
                    this.vy += 0.1; // Gravity
                    this.alpha -= 1 / this.life;
                    if (this.alpha < 0) this.alpha = 0;
                }
                
                draw() {
                    ctx.beginPath();
                    ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
                    ctx.fillStyle = `hsla(${this.color}, 100%, 50%, ${this.alpha})`;
                    ctx.fill();
                }
            }
            
            class Firework {
                constructor(x, y) {
                    this.x = x;
                    this.y = y;
                    this.rocketY = canvas.height;
                    this.rocketVY = -10 - Math.random() * 5;
                    this.exploded = false;
                    this.particles = [];
                    this.color = Math.random() * 360;
                    this.trail = [];
                }
                
                update() {
                    if (!this.exploded) {
                        // Rocket phase
                        this.rocketY += this.rocketVY;
                        this.rocketVY += 0.05; // Slow down slightly
                        this.trail.push({x: this.x, y: this.rocketY, alpha: 1});
                        
                        // Trail fade
                        this.trail = this.trail.map(t => ({...t, alpha: t.alpha - 0.05}));
                        this.trail = this.trail.filter(t => t.alpha > 0);
                        
                        if (this.rocketVY >= 0 || this.rocketY <= this.y) {
                            this.explode();
                        }
                    } else {
                        // Update particles
                        this.particles.forEach(p => p.update());
                        this.particles = this.particles.filter(p => p.alpha > 0);
                    }
                }
                
                draw() {
                    if (!this.exploded) {
                        // Draw trail
                        this.trail.forEach(t => {
                            ctx.beginPath();
                            ctx.arc(t.x, t.y, 2, 0, Math.PI * 2);
                            ctx.fillStyle = `hsla(${this.color}, 100%, 50%, ${t.alpha * 0.5})`;
                            ctx.fill();
                        });
                        // Draw rocket
                        ctx.beginPath();
                        ctx.arc(this.x, this.rocketY, 3, 0, Math.PI * 2);
                        ctx.fillStyle = `hsl(${this.color}, 100%, 70%)`;
                        ctx.fill();
                    } else {
                        this.particles.forEach(p => p.draw());
                    }
                }
                
                explode() {
                    this.exploded = true;
                    const particleCount = 100 + Math.random() * 50;
                    for (let i = 0; i < particleCount; i++) {
                        const angle = Math.random() * Math.PI * 2;
                        const speed = 1 + Math.random() * 5;
                        const vx = Math.cos(angle) * speed;
                        const vy = Math.sin(angle) * speed - 2; // Initial upward boost
                        const size = 2 + Math.random() * 2;
                        const life = 50 + Math.random() * 50;
                        const colorOffset = Math.random() * 60 - 30;
                        this.particles.push(new Particle(this.x, this.y, vx, vy, this.color + colorOffset, size, life));
                    }
                }
            }
            
            // Global variables
            let fireworks = [];
            let stars = []; // Background stars
            
            // Generate background stars
            function generateStars() {
                stars = [];
                for (let i = 0; i < 200; i++) {
                    stars.push({
                        x: Math.random() * canvas.width,
                        y: Math.random() * canvas.height,
                        size: 1 + Math.random() * 2,
                        alpha: Math.random()
                    });
                }
            }
            generateStars();
            window.addEventListener('resize', generateStars);
            
            // Launch firework on click/touch
            function launchFirework(x, y) {
                const explodeHeight = 100 + Math.random() * (canvas.height / 2);
                fireworks.push(new Firework(x, explodeHeight));
            }
            
            canvas.addEventListener('click', (e) => {
                launchFirework(e.clientX, e.clientY);
            });
            
            canvas.addEventListener('touchstart', (e) => {
                e.preventDefault();
                for (let i = 0; i < e.touches.length; i++) {
                    const touch = e.touches[i];
                    launchFirework(touch.clientX, touch.clientY);
                }
            });
            
            // Animation loop
            function animate() {
                ctx.fillStyle = 'rgba(0, 0, 0, 0.1)'; // Trail effect
                ctx.fillRect(0, 0, canvas.width, canvas.height);
                
                // Draw stars
                stars.forEach(star => {
                    ctx.beginPath();
                    ctx.arc(star.x, star.y, star.size, 0, Math.PI * 2);
                    ctx.fillStyle = `hsla(0, 0%, 100%, ${star.alpha * 0.5})`;
                    ctx.fill();
                });
                
                // Update and draw fireworks
                fireworks.forEach(fw => {
                    fw.update();
                    fw.draw();
                });
                fireworks = fireworks.filter(fw => !fw.exploded || fw.particles.length > 0);
                
                requestAnimationFrame(animate);
            }
            
            animate();
            
            // Auto-launch some fireworks to start
            setInterval(() => {
                if (fireworks.length < 5 && Math.random() < 0.3) {
                    launchFirework(Math.random() * canvas.width, Math.random() * canvas.height);
                }
            }, 1000);
        </script>
    </body>
    </html>
    

    How to Use:

    1. Save this code as an .html file (e.g., fireworks.html).
    2. Open it in a modern web browser (Chrome, Firefox, etc.).
    3. Click or tap anywhere on the screen to launch fireworks. It supports multiple touches on mobile for simultaneous launches!
    4. Sit back and be amazed by the colorful explosions, particle physics, trails, and starry background. It's interactive, performant, and visually stunning – all in one file!

    This web app creates a mesmerizing fireworks display with realistic physics (gravity, fading), random colors, and a cosmic backdrop. It auto-launches some fireworks to keep the show going, but your interactions make it truly spectacular. Enjoy the awe! 🚀🎆

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.