Limited Support
Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.
Hi there,
I notice there is a 13kb roughly of inline CSS called "wpdiscuz-frontend-css-inline-css" injected.
I cannot remove this and ultimately do not want this to be loaded inline. In fact, it doesn't make sense for comments to load anything inline, since it is not above the fold, or cacheable.
How can I remove this specifically and other CSS so I can then manually load this at the footer as an external file?
Hi,
This inline CSS is dynamically generated, so it uses inline logic. For example, if you change a color, the CSS will update accordingly. It cannot be stored in a separate file, as doing so would break the logic.
My colors are set in stone and never going to change, neither are any of the settings in wpdiscuz - can you provide some code to disable it inline and I'll load the same CSS as an external file?
I appreciate that, but you can at least tell me where the inline code is being injected - so I at least comment it out, or better yet, some php that blocks it from loading?
Well I mean I am not a coder but I asked ChatGPT and in 10 seconds it produced this for all inline:
add_action('template_redirect', function () {
ob_start(function ($html) {
// Match all <style> tags (in head or body)
preg_match_all('/<style.*?>(.*?)<\/style>/is', $html, $matches);
if (!empty($matches[1])) {
$css = implode("\n\n", $matches[1]);
// Save to a CSS file (e.g., /wp-content/uploads/inline-css.css)
$file_path = WP_CONTENT_DIR . '/uploads/inline-css.css';
file_put_contents($file_path, $css);
// Remove all inline <style> blocks
$html = preg_replace('/<style.*?>.*?<\/style>/is', '', $html);
// Add link to new external CSS file in head
$link_tag = '<link rel="stylesheet" href="' . content_url('uploads/inline-css.css') . '">';
$html = preg_replace('/<\/head>/', $link_tag . "\n</head>", $html);
}
return $html;
});
});
So I think with 2 minutes of your team looking at it, you could provide something useful?
I get it, but can you at least provide me code to remove the inline wpdiscuz produces, or tell me where to comment this out, so I can load it myself as an external file?