How Does Google's DVD Screensaver Easter Egg Work?
Typing "DVD screensaver" into Google Search triggers a built-in Easter egg that makes the Google logo detach from the top of the results page and bounce around your browser window. The effect mimics the classic idle screen of a DVD player by using client-side JavaScript and CSS to animate the logo's position, detect collisions with the edges of your viewport, and change its color on every bounce.
Triggering the Easter Egg
When you submit a search query, Google's servers check whether your
query matches a list of known Easter eggs. For "DVD screensaver," the
search results page loads normally, but it also includes a small,
specialized JavaScript snippet. After a brief moment, this script
targets the Google logo element in the page's Document Object Model
(DOM) and switches its CSS positioning to fixed. Using
fixed positioning detaches the logo from the normal flow of the webpage
so it can float freely over the search results without shifting any text
or links around.
How the Bouncing Animation Works
Once the logo is detached, the script runs a continuous animation
loop—typically powered by window.requestAnimationFrame()—to
update the logo's coordinates on the screen smoothly at your monitor's
refresh rate.
The movement relies on basic two-dimensional kinematics:
- The logo is given a horizontal velocity (\(v_x\)) and a vertical velocity (\(v_y\)).
- On each frame, its current position \((x, y)\) is updated by adding the velocity values: \(x_{\text{new}} = x + v_x\) and \(y_{\text{new}} = y + v_y\).
- These new coordinates are applied to the logo using CSS
transform: translate(...)ortopandleftproperties.
Edge Detection and Color Changes
To keep the logo inside your browser window, the script checks the
logo's bounding box against the dimensions of the viewport
(window.innerWidth and window.innerHeight) on
every frame:
- Horizontal bounce: If the logo's left edge reaches \(0\) or its right edge reaches the viewport width, the script reverses its horizontal direction by multiplying \(v_x\) by \(-1\).
- Vertical bounce: If the logo's top edge reaches \(0\) or its bottom edge reaches the viewport height, it reverses its vertical direction by multiplying \(v_y\) by \(-1\).
Just like a real DVD player, the logo also changes color whenever it hits an edge. The script cycles through Google's signature brand colors (blue, red, yellow, and green) by updating the fill color of the logo's SVG paths or applying a CSS filter each time a collision is detected.
Resizing and Corner Hits
Because the animation reads the browser's innerWidth and
innerHeight dynamically, resizing your browser window
immediately changes the boundaries of the bounce area. If you shrink the
window, the logo will bounce off the new, smaller edges. And just like
the classic DVD screensaver, if the logo's aspect ratio and starting
coordinates align with the dimensions of your window, it can
occasionally hit a corner cleanly—reversing both \(v_x\) and \(v_y\) at the exact same time.