Skip to content
Front-end optimisation

Snowfall in Your Shop: Holiday Decor Without Slowdowns

Snowfall scripts, glitter borders and GIF banners slow down weak smartphones. How to keep holiday decorations in your shop smooth and your INP stable.

17 min read AnimationenINPFrontendWeihnachten

In short and in plain language

During Advent, many shops show snow and glitter. It looks nice. On an old phone, it can use a lot of power. Then the shop is slow to react to a tap.

Snow made with a script works all the time. Snow made with CSS is lighter. The browser can move it with little effort.

When the tab is hidden, the snow should rest. Some people want less motion. For them, the snow stays still.

Snow fits on the home page. It does not belong in the cart or at checkout. In January, the snow and glitter go away for good.

We test your shop with and without the snow. Then we change the snow so it slows the shop down less.

By late November, many shops have put up their holiday decorations: snow drifts across the header, borders glitter, and an animated banner announces the gift selection. A lot is at stake for online retail: HDE expects online sales of 23.1 billion euros for November and December 2026, a nominal 4.1 percent more than the year before (HDE). Anyone who shops on an older smartphone during these weeks, however, has far less computing power than the machine the decorations were designed on. A snowfall script calculates on the main thread in every frame, and that is exactly where taps on filters, size pickers and the buy button wait their turn. This article shows how to add snow, glitter and banners so the mood stays and INP does not suffer: CSS transforms instead of a canvas loop, pausing in background tabs, respect for reduced motion, decorations on landing pages only and a planned removal in January. Countdown timers and promo bars are out of scope here; they are covered in our article on promo banners without layout shift.

Key takeaways

  • A snowfall script with a canvas loop redraws every frame on the main thread. For an animation to stay smooth, your own work per frame should be done within 10 milliseconds (web.dev); otherwise it stutters and input has to wait.
  • Snowflakes as elements animated only with CSS transform and opacity can be moved by the browser without layout or paint. Even so, non-composited animations still appear on 40 percent of mobile pages (Web Almanac 2025).
  • In a background tab, requestAnimationFrame pauses in most browsers (MDN), while timer loops keep running in throttled form. A visibilitychange handler stops snow and glitter until the tab is visible again.
  • With prefers-reduced-motion: reduce, the snow stands still. Motion that starts automatically and lasts more than five seconds needs a way to pause it (WCAG 2.2).
  • Decorations belong on the home page and campaign pages, not in the cart and checkout. On mobile, 80 percent of home pages achieve good INP, but only 69 percent of secondary pages (Web Almanac 2025).
  • Measure with CPU throttling in DevTools, at 20x for low-end mobile devices (Chrome for Developers), and with INP field data. In January, script, styles and images are removed from the templates entirely instead of just being hidden.

Why snowfall weighs on the main thread

Most screens refresh 60 times per second, which leaves 16.66 milliseconds per frame (web.dev). Because the browser needs part of that for its own housekeeping, web.dev recommends that your own work be done within 10 milliseconds (web.dev). Miss that budget and the frame rate drops and the page stutters. Many devices now draw even faster: besides 60 hertz, 120 hertz and 144 hertz are also widely used (MDN). An animation driven by requestAnimationFrame is then called more often, and the time window per frame shrinks.

A typical snowfall script works at exactly this pace. In every frame it calculates fall speed and sideways drift for each flake, clears the drawing surface and paints all flakes again. That happens on the main thread, the same thread that handles clicks, calculates styles and builds the layout. It processes one task after another, and any task longer than 50 milliseconds counts as a long task (web.dev). A single pass of the snow loop is rarely that long. The problem is the total: the loop occupies the thread for a slice of every frame, scripts for search, cart and analytics come on top, often including third-party scripts, and on a weak device the gaps in between are no longer enough for a quick response to a tap.

That is exactly what Interaction to Next Paint measures. It captures the time from an input to the next painted frame; up to 200 milliseconds counts as good, above 500 milliseconds as poor (web.dev). Lighthouse spells out the risk for animations: non-composited animations require more work and can appear janky on low-end phones or when performance-heavy tasks run on the main thread (Chrome for Developers). The Web Almanac shows this is no niche issue: such animations appear on 40 percent of mobile and 44 percent of desktop pages (Web Almanac 2025). And the gap between device classes is wide: 77 percent of websites achieve good INP on mobile, compared with 97 percent on desktop (Web Almanac 2025). How to lower INP in general is covered in our guide to optimizing INP.

Canvas loop or CSS transform

Canvas is tempting for snow: one drawing surface over the header, a few lines of JavaScript, as many flakes as you like. The price lies in how it runs. Canvas logic and rendering happen on the same thread as user interaction, and the sometimes heavy computations involved in animations can harm real and perceived performance (web.dev). Pixel density adds to this: if you enlarge the drawing surface by the device pixel ratio for sharp output on high-resolution displays, the browser has to fill a multiple of the pixels in every frame.

CSS animations take a different route. If an animation only changes properties that trigger neither layout nor paint, the browser jumps straight to compositing the layers, the cheapest path through the pixel pipeline (web.dev). In practice, flakes move via transform, fade in and out via opacity, and nothing else is touched. When an element is promoted to its own layer, the transform animation can be handled on the GPU, which is more efficient especially on mobile devices (MDN). The main thread then no longer has to calculate new positions in every frame.

snow.css
/* Snow in the header: movement via transform only */
.snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.snow i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: snowfall 10s linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes snowfall {
  to { transform: translate3d(24px, 260px, 0); }
}
/* Pause in a background tab or outside the viewport */
.snow.is-paused i { animation-play-state: paused; }

Four details make the difference. The container carries aria-hidden="true" so screen readers skip the empty elements. pointer-events: none ensures the snow layer does not swallow clicks that are meant for the menu or the search. overflow: hidden keeps the flakes inside the header so no scrollbar appears. And movement runs through transform rather than top or left: animating an element's position forces the browser to check other elements, recalculate the layout and repaint (web.dev). The horizontal position and delay of each flake sit directly on the element as CSS variables, for example <i style="--x: 12%; --delay: -4s">, so the snow does not fall in lockstep. More on the pipeline and on tracking down stutter is in our article on smooth animations.

ApproachWork per frameMain threadUse in a shop
Canvas loop with requestAnimationFramerecalculate and redraw all flakesconstantly busy, grows with flake count and pixel densityonly with few flakes and a background pause
Flakes as elements, position set by JavaScriptset the style of every flake, often with new layoutbusy, plus layout and paint workavoid
Flakes as elements, CSS animation with transformmove layerslargely freedefault for subtle snow
OffscreenCanvas in a web workerdrawing in the workerfree, the worker carries the loadwhen canvas is really needed

If it has to be canvas, for instance for a more elaborate effect, the drawing work can move to a web worker with OffscreenCanvas. The interface decouples drawing from the DOM, and transferControlToOffscreen() mirrors a regular canvas into the worker (web.dev). A busy main thread then no longer stops the animation, and in turn the animation no longer slows down input. What that looks like in code is shown in our article on web workers. If you stay with a regular canvas, follow the MDN advice: pre-render repeating shapes once on an intermediate canvas, use integer coordinates and draw static backgrounds with CSS instead of on every tick (MDN).

How many snowflakes a shop can handle

The CSS approach has a limit too, and it lies in the number of elements. Every flake is a node in the DOM. Up to Lighthouse 12, the DOM size audit warned when the body contained more than about 800 nodes and reported an error above about 1,400 nodes (Chrome for Developers). Since Lighthouse 13, it has moved into the "Optimize DOM size" insight (Chrome for Developers), which looks at large layout and style recalculations instead of a fixed node count; as an order of magnitude, the old thresholds still hold. A shop header with navigation, product tiles and footer already brings many nodes; how much a mega menu alone can add is described separately. For subtle snow, a manageable number of fixed elements spread over a few animation durations is enough. Every additional animated flake means more style calculation and usually another layer for the browser to manage.

  • Limit the flakes: a fixed, manageable number of elements in the markup instead of a script loop that keeps creating new flakes.
  • Show fewer on mobile: use a media query to take part of the flakes out of layout and rendering on small screens with display: none.
  • Keep it to the header: do not lay the snow over the whole page as a fixed layer, only over the area where it belongs to the design.
  • Do not animate shadows: box-shadow, colors and background images are among the properties whose changes trigger a new paint (web.dev).
  • Load the shape once: a flake as a small SVG or as the element background, loaded once and then only moved.

Pausing in background tabs and outside the viewport

People comparing gifts like to leave shop tabs open in the background. Whatever keeps running there costs battery and computing time without anyone seeing it. Browsers throttle this on their own, but to different degrees. Callbacks via requestAnimationFrame pause in most browsers in background tabs and hidden iframes to improve performance and battery life (MDN). A snowfall script built on setInterval or chained setTimeout calls, on the other hand, keeps running, only throttled.

Chrome shows how this throttling is staged. When a page is hidden, the browser usually checks such timers only once per second (Chrome for Developers). With Chrome 88, a heavier stage was added (Chrome for Developers): if the page has been hidden for more than 5 minutes, the script chains its timers and the page plays no audio, Chrome checks them only once per minute (Chrome for Developers). For animations, the same article recommends requestAnimationFrame or CSS animations instead of timers. Still, do not rely on this automatic behavior, because the rules differ between browsers and only apply once the tab really is in the background.

It is safer to control the pause yourself. The Page Visibility API fires the visibilitychange event when a tab moves to the background or the window is minimized or completely covered (MDN). A handler then sets a class that stops all decorative animations and removes it again on return. For snow that has scrolled out of view, an IntersectionObserver does the same: once the header is no longer visible, the snow stops.

decor-pause.js
// Pause the decor when the tab is hidden or the header scrolls out of view
const decor = document.querySelector('.snow');
let tabHidden = document.hidden;
let offscreen = false;

const update = () =>
  decor.classList.toggle('is-paused', tabHidden || offscreen);

document.addEventListener('visibilitychange', () => {
  tabHidden = document.hidden;
  update();
});

new IntersectionObserver(([entry]) => {
  offscreen = !entry.isIntersecting;
  update();
}).observe(decor);

The same principle applies to a canvas loop: call cancelAnimationFrame() when the page goes to the background and restart the loop on return. Make sure to reset the time measurement as you do. Otherwise the first frame after the pause calculates with the entire elapsed time, and the flakes jump down in one go.

Glitter borders, string lights and GIF banners

Glittering borders and blinking string lights are often more expensive than snow, because they usually rely on properties that trigger a new paint. A pulsing box-shadow, a moving gradient or a changing border color skip layout but still require new pixels in every frame (web.dev). A cheaper option is a pseudo-element carrying the finished shine that only fades in and out via opacity or moves via transform. will-change helps only in exceptional cases: MDN describes the property as a last resort for existing performance problems, and overusing it can slow the page down instead of speeding it up (MDN).

With lights, a second limit applies. Under WCAG, content must not flash more than three times in any one second period, unless the flash is below the general flash and red flash thresholds (WCAG 2.2). A slow glow of the string lights is therefore unproblematic, a fast flicker is not.

For animated GIF banners, one sentence is enough here because we cover the topic in detail elsewhere: in the web.dev example, the same animation weighs 3.7 MB as a GIF and only 551 KB as an MP4 (web.dev), and how to embed the video is explained in our articles on load times caused by video and on client-side image processing in WordPress 7.1.

When visitors want less motion

Anyone who has set their operating system to show as little motion as possible passes that setting on to the page through the prefers-reduced-motion media query. Animations such as scaling or panning large objects can trigger discomfort for people with vestibular motion disorders (MDN). For snow this means: with reduce, the flakes stand still or disappear entirely. Independently of that, WCAG states that anything moving which starts automatically, lasts more than five seconds and is shown alongside other content needs a way to pause, stop or hide it (WCAG 2.2).

decor-motion.css
/* Less motion requested: snow stands still, shine stays calm */
@media (prefers-reduced-motion: reduce) {
  .snow i { animation: none; }
  .glow::after { animation: none; }
}

Because snowfall is pure decoration, the choice is easy. A small switch in the header that pauses the decorations usually covers the requirement and uses the same is-paused class that also controls the background pause. For the switch itself to be easy to use, it needs a clear label, keyboard operation and a remembered state across page changes.

Decor on landing pages, not in checkout

A simple rule often goes a long way: snow and glitter belong where mood sells, that is on the home page, on campaign and theme pages and at most on category pages with gift ideas. Decorations have no place in the cart, checkout or customer account. There, every input counts, from changing a quantity to entering an address, and every delay hits someone who already wants to buy. How much headroom remains at the buy button is described in our article on INP at the add-to-cart button.

Field data supports this split. According to page-level CrUX data, 80 percent of home pages achieve good INP on mobile, compared with 69 percent of secondary pages (Web Almanac 2025). The authors point out that secondary pages often contain more complex interactions such as filters, carousels and form validation and also carry JavaScript from third-party widgets and analytics (Web Almanac 2025). That is exactly where no snow loop should compete for computing time.

Technically, this means the decoration script and styles load only in the templates that show them, not globally in the theme. In Shopware, this can be handled through the layout of the relevant shopping experience or a dedicated block in the affected templates; in other systems, through conditional loading per page type. A stylesheet that loads everywhere and merely hides the flakes in checkout with display: none saves the animation there, but not the transfer. How we check themes and extensions in Shopware for such loads is described on our page about Shopware performance.

  • Home page and campaign pages: subtle snow in the header, a banner as video instead of GIF.
  • Category pages with gift ideas: at most a calm motif, no animation over the product tiles.
  • Product pages: decoration at most as a static image; the gallery and variant selection need the computing time.
  • Cart, checkout and customer account: no decorations, no decoration scripts, no decoration styles.

Measure on weak devices, not on the developer machine

A fast laptop will not tell you whether the decorations hold up. Chrome for Developers advises recording every profile with CPU throttling, because mobile devices have much less CPU power than desktops. The guide itself uses a 4x slowdown in its example (Chrome for Developers); to make sure a page works well on low-end mobile devices, the same guide says to set 20x (Chrome for Developers). In the DevTools Performance panel you then see how much time per frame goes to scripting, style calculation and painting, and whether there are still gaps for input between frames. Why throttling does not replace a real reference device is explained in our article target device, not test device. How a shop can scale back effects on weak devices from the outset is described in the article on CPU tiers in the browser.

  1. Record without decorations: profile the home page with 4x and, for low-end devices, also with 20x CPU throttling while opening the menu, tapping the search and switching to a category.
  2. Repeat with decorations: the same steps with snow, glitter and banner active, in the same order and for a similar duration.
  3. Compare frames: put the share of scripting and painting per frame, long tasks and dropped frames of both recordings side by side.
  4. Read Lighthouse: the non-composited animations audit lists the affected elements along with the reason (Chrome for Developers); how we evaluate such reports is part of our Lighthouse audit.
  5. Watch field data: compare the INP of the home page in the days after the change with the period before and with pages without decorations.

For field data, a look at your own measurement or the report on Core Web Vitals is enough. Because the mix of visitors and devices can also shift in December, compare pages with and without decorations over the same period instead of comparing the month with the previous one. How to attribute long frames to individual scripts is shown in our article on long animation frames, and how to read the values directly in the browser in the article on live metrics in DevTools.

Plan the removal in January from the start

Decorations still running in February no longer carry any mood; they are just dead weight. Plan the removal when you add them: a fixed end date on which script, styles and images disappear from the templates, and a named person who briefly checks the removal afterwards. A switch in the configuration or a time window in the theme is practical, so the decorations end without a new release. The difference between hiding and removing matters: a banner that is only hidden can keep loading its file, and a script that merely no longer starts is still transferred and parsed. If you keep a JavaScript performance budget, count decoration scripts in it like any other script.

A second measurement after the removal pays off. It shows whether everything is really gone and provides the comparison values for next year. If you build the decorations as a separate module with a clear integration point, you can switch them back on next November with a few steps instead of starting over, and you only need to repeat the measurement rather than set it up again.

How we review your holiday decor

In our front-end optimization, the review starts with recordings of your home page and campaign pages on a throttled CPU, each with and without decorations. We check which animations run on the main thread, whether snow and glitter keep calculating in the background and whether decoration scripts are loaded in checkout. The result is a short list of changes, from switching to CSS transforms to loading on landing pages only, which we implement and back up with measurements before and after the change.

If you want an overview of all bottlenecks first, start with a technical analysis. Besides the decorations, it shows whether other items such as large images or third-party scripts would bring more, and it puts the values of your most important templates into context. We are happy to answer questions about the process via our contact form.

Sources

This article is based on data from: Chrome for Developers (Lighthouse: Avoid non-composited animations, Avoid an excessive DOM size; Heavy throttling of chained JS timers beginning in Chrome 88; Analyze runtime performance); web.dev (Rendering performance, How to create high-performance CSS animations, Interaction to Next Paint, Optimize long tasks, OffscreenCanvas, Replace animated GIFs with video); MDN Web Docs (requestAnimationFrame(), Page Visibility API, prefers-reduced-motion, Optimizing canvas, will-change, CSS and JavaScript animation performance); HTTP Archive Web Almanac 2025 (Performance chapter); W3C (WCAG 2.2); German Retail Federation (HDE, forecast for the 2026 holiday season).

Related Articles

Front-end optimisation

Browser Targets with Baseline: Drop Polyfills Nobody Needs

How much polyfill weight does your shop ship for old browsers? Find your build target, set a Baseline target, measure legacy code and check visitor data.

17 min read
Shops & CMS

Images in the browser: what WordPress 7.1 changes on upload

WordPress 7.1 resizes and encodes images in the browser during upload. What that changes for files, formats, GIFs and server load, and how to measure it.

18 min read
Server & hosting

Fluctuating Response Time: When Your Server Shares CPU

Response time swings with no change to your shop? Shared CPU time may be the cause. How to measure steal time, run the counter-checks and choose a remedy.

20 min read