Nestable Slider stays invisible until DOMContentLoaded, which delays LCP: please output pre-init layout CSS

Hello,

I was trying to optimize my product pages that have splide slider loading right at the top of the page and found that there’s room for improvement. This is the report from Claude which I hope it’s helpful :

Bricks version: 2.4.3 Element: Nestable Slider (slider-nested), options type Custom: type slide, perPage 3 (2 on tablet, 1 on mobile), gap var(--space-s), right padding 10rem, arrows on Used as: the WooCommerce product gallery on the single product template, so the first slide image is the page’s Largest Contentful Paint (LCP) element

What happens

The first slide image is preloaded, fetchpriority="high" and not lazy-loaded. It finishes downloading early, yet the browser doesn’t paint it until the slider is mounted.

The reason is Splide’s core CSS that Bricks loads:

.splide{position:relative;visibility:hidden}

.splide.is-initialized,.splide.is-rendered{visibility:visible}

Bricks mounts its sliders from bricks.min.js in a DOMContentLoaded handler. DOMContentLoaded waits for every deferred script on the page, so the slider stays visibility:hidden until the last deferred script has run. On a WooCommerce site with a typical plugin stack that is a long time.

Lighthouse’s LCP breakdown shows it clearly: TTFB 20 ms, resource load delay ~150 ms, resource load ~50 ms, then element render delay 1.3–2.2 s (unthrottled), with LCP landing right after DOMContentLoaded every time. When Splide mounts it also causes a layout shift (CLS 0.11–0.27 on our product pages), because the slides move from their unstyled positions to the Splide layout.

Feature request

Bricks already knows every slider setting on the server (perPage per breakpoint, gap, padding, type). It could print a small block of CSS per Nestable Slider that lays out the first slides exactly as Splide will, scoped to :not(.is-initialized), so they paint with the first render and Splide takes over without a visual change. Splide itself provides the is-rendered class for this kind of pre-rendered state.

An option such as “Render slides before JavaScript (improves LCP/CLS)”, or simply doing it by default for type: slide / loop, would remove the problem for everyone using a slider above the fold: hero sliders, product galleries.

A second, smaller improvement: mount sliders as soon as bricks.min.js executes, if the slider markup is already in the DOM, instead of waiting for DOMContentLoaded.

Workaround I’m using for now

<?php
$s = '.my-gallery-slider.splide:not(.is-initialized)';
$css = $s . '{visibility:visible}'
  . $s . '>.splide__track{overflow:hidden;position:relative;padding-left:0;padding-right:10rem}'
  . $s . '>.splide__track>.splide__list{display:flex;margin:0;padding:0}'
  . $s . '>.splide__track>.splide__list>*{flex-shrink:0;height:fit-content;margin-right:var(--space-s);width:calc((100% + var(--space-s))/3 - var(--space-s))}'
  . '@media (max-width:768px){' . $s . '>.splide__track>.splide__list>*{width:calc((100% + var(--space-s))/2 - var(--space-s))}}'
  . '@media (max-width:480px){' . $s . '>.splide__track>.splide__list>*{width:100%}}';
echo '<style id="gallery-preinit">' . $css . '</style>' . "\n";

Inline CSS in wp_head (priority 1) on product pages, mirroring the slider’s settings by hand. .my-gallery-slider is a class on the Nestable Slider:

It works, but it is fragile. The CSS duplicates the slider’s settings, so changing perPage, gap or padding in the builder silently breaks it. That is why a native solution would be much better.

Steps to reproduce

  1. Add a Nestable Slider near the top of a page with 3+ image slides. Set the first image to eager loading / high fetch priority. (edit: Perfmatters plugin handles this for me)
  2. Add a few deferred scripts to the page (any plugins), or simply throttle the CPU in DevTools.
  3. Record a Performance trace with mobile emulation. The image request finishes early, but LCP fires only after DOMContentLoaded, when Splide adds is-initialized, and there is a layout shift at that moment.
  4. Add the pre-init CSS above. LCP moves to first paint and the shift disappears.