Help  /  WP Rocket and unstyled banners

Cookie banner appears unstyled with WP Rocket

If your site uses WP Rocket and your cookie banner shows up as plain text at the bottom of the page, under your footer, one WP Rocket setting is hiding its design. The fix takes a couple of minutes.

What you might see:

  • “We value your privacy” and the banner text as plain text below your footer
  • the buttons (Accept All, Manage preferences, Save Preferences, Decline All) as plain buttons or links, with the category tick boxes next to them
  • the small cookie icon, which normally floats in a corner, sitting in the page instead

Your tracking is still held back. CookieFlame keeps blocking tracking until a visitor makes a choice, so nothing runs before they agree. But because visitors don’t see a proper banner, hardly anyone makes a choice, and your analytics and ads stay off for them. So it’s worth fixing straight away.

Why it happens

WP Rocket has a speed feature called Remove Unused CSS. CSS is the part of a website that controls how things look. WP Rocket checks each page, keeps only the design rules it can see being used, and drops the rest. CookieFlame adds its banner just after the page has loaded, so WP Rocket doesn’t see the banner when it checks. It decides the banner’s design isn’t needed and leaves it out. The fix is to tell WP Rocket to always keep CookieFlame’s design file.

How to fix it

  1. In WordPress, go to Settings → WP Rocket and open the File Optimization tab.
  2. Find Optimize CSS delivery. With Remove Unused CSS chosen, you’ll see a box called CSS safelist.
  3. Add this on a line of its own, and leave any lines that are already there:
    /wp-content/plugins/cookieflame/(.*).css
  4. Click Save Changes.
  5. In the bar at the top of the screen, open the WP Rocket menu and click Clear Used CSS. If you don’t see it, click Clear and preload cache instead.
  6. If you use Cloudflare or another CDN, or your host has its own cache, clear that too.

You only need this one line, whether you use free CookieFlame or CookieFlame Pro. Pro uses the same banner, so it has no separate design file.

CookieFlame works with WP Rocket and other caching tools, so once this line is in place you keep your fast pages and a banner that looks right.

Check that it worked

  1. Open your site in a private (incognito) window, so you’re not logged in.
  2. The banner should appear as a card at the bottom of the screen, with proper buttons. Click Manage preferences: the categories should show as switches. Once you’ve made a choice, the small cookie icon should sit in a corner of the screen.
  3. Still plain? Wait a few minutes and reload the page once or twice. WP Rocket rebuilds each page’s design when someone visits it, so the fix can take a visit or two to show.
  4. For a closer look, right-click the page, choose View page source and search it (Ctrl+F, or Cmd+F on a Mac) for cookieconsent.css. If it’s there, CookieFlame’s design file is loading. If it isn’t, search for cc-banner instead: it should appear inside the block that starts with <style id="wpr-usedcss">.

Still unstyled?

  • Check the line in the CSS safelist is exactly as shown above, with nothing else on that line.
  • Some hosts and security plugins move the plugins folder to a different address. If yours does, add these three lines to the CSS safelist as well, each on its own line, then save and clear the Used CSS again:
    #cc-banner
    #cc-(.*)
    .cc-(.*)
  • Still stuck? Contact us and we’ll help.

Using a different speed plugin?

Other speed plugins have a similar “remove unused CSS” feature, and it can cause the same problem. The fix is the same idea: tell the plugin to keep CookieFlame’s design. After the change, check your site the same way as above.

  • LiteSpeed Cache: go to LiteSpeed Cache → Page Optimization and open the CSS tuning tab. Add cookieflame/assets/css/ to UCSS Inline Excluded Files (called UCSS File Excludes and Inline in older versions). Save, then click Purge All.
  • Perfmatters: go to Perfmatters’ CSS settings. Under Remove Unused CSS, add cookieflame/assets/css/ to Excluded Stylesheets. Save, click Clear Used CSS, then clear any other caches.
  • FlyingPress: in the Remove unused CSS settings, add #cc- and .cc- to Include CSS Selectors, each on its own line. Save, then clear the cache.
  • NitroPack: in your NitroPack dashboard, go to Settings → Cache → Excluded Resources. Add *cookieconsent.css*, choose CSS as the type and Remove unused CSS as the operation. Save, then purge the cache.