The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Inline of style "wp...
 
Share:
Notifications
Clear all

Issue Inline of style "wpdiscuz-frontend-css-inline-css"

9 Posts
2 Users
0 Reactions
95 Views
Posts: 24
Topic starter
(@willgreeny)
Eminent Member
Joined: 3 years ago

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?

 

8 Replies
Asti
Posts: 8066
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 years ago

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.

Reply
Posts: 24
Topic starter
(@willgreeny)
Eminent Member
Joined: 3 years ago

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?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8066

@willgreeny 

I'm sorry, but currently there is not any solution for this. 

Reply
Posts: 24
Topic starter
(@willgreeny)
Eminent Member
Joined: 3 years ago

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?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8066

@willgreeny 

The team has added this to our to-do list. We cannot provide an exact ETA for when it will be implemented, but I’ll update this topic once it’s included.

I’m sorry, but there’s currently no solution. If you comment it out, the entire CSS will be commented out.

Reply
Posts: 24
Topic starter
(@willgreeny)
Eminent Member
Joined: 3 years ago

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?

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8066

@willgreeny 

We do not provide any guarantee for the code shared by ChatGPT or other community members. You are free to test the code and see if it works for your case. However, we won’t be able to offer support for any issues that may arise as a result of using it.

The answer I’ve provided was discussed with the team, and there’s nothing more I can add at this point:   https://wpdiscuz.com/community/troubleshooting/inline-of-style-wpdiscuz-frontend-css-inline-css/#post-28952

Reply
Posts: 24
Topic starter
(@willgreeny)
Eminent Member
Joined: 3 years ago

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?

Reply
Share: