WordPress theme: Font scaling with clamp() stops working after logging out

I’m having a weird issue with my new WordPress theme. I set up fluid typography for font scaling. It works great when I’m logged in as admin, but something strange happens when I log out.

The browser suddenly can’t understand the clamp() function for font sizes. It says it’s an invalid property value and uses a fallback instead. Here’s what my CSS looks like:

.my-text {
  font-size: 3.875rem; /* Fallback used when logged out */
  font-size: min(max(1.5rem, 3vw + 0.9rem), 3.875rem);
  font-size: clamp(1.5rem, 3vw + 0.9rem, 3.875rem); /* Works when logged in */
}

Any ideas why this might be happening? Is there some WordPress setting that could be affecting CSS interpretation for logged-out users? I’m stumped!

This is indeed a perplexing situation. One possibility to consider is that your WordPress setup might be using a CSS minification or optimization tool that’s configured differently for logged-in and logged-out users. These tools sometimes strip out newer CSS features like clamp() for broader browser compatibility.

To troubleshoot, I’d suggest temporarily disabling any performance optimization plugins you have installed. If that doesn’t work, you could try adding the clamp() styles via WordPress’s customize additional CSS feature instead of directly in your theme files. This might bypass any optimization processes.

Another approach would be to use a polyfill for clamp() to ensure it works across all browsers and user states. There are several JavaScript-based solutions available that can emulate clamp() functionality in older browsers.

strange issue! have u checked if any caching plugins r messing with CSS? sometimes they strip out ‘advanced’ CSS for performance. also, maybe ur theme has separate stylesheets for logged-in/out users? worth checking theme files. lastly, try disabling plugins 1 by 1 to see if any interfere.

I’ve run into similar issues before, and it’s usually related to how WordPress handles caching and optimization for different user roles. One thing that worked for me was using a CSS custom property (variable) approach instead of direct clamp() usage. Here’s what I mean:

:root {
  --fluid-text: clamp(1.5rem, 3vw + 0.9rem, 3.875rem);
}

.my-text {
  font-size: 3.875rem; /* Fallback */
  font-size: var(--fluid-text);
}

This method seemed to bypass whatever was causing the clamp() function to break for logged-out users in my case. It’s worth a shot if you haven’t tried it yet.

Also, double-check your server’s mod_security rules if you’re on Apache. Sometimes overzealous security settings can interfere with CSS parsing for non-authenticated users. Took me ages to figure that one out on a client’s site once!