• Hello Helpers !

    I have a small problem here: I did a SEO test for my WordPress site with GTMETRIX and I got some errors that I wish to fix all to increase my SEO score and become more friendly with search engines (especially with Google).

    They told me to Inline my small css files like the subscriptions.css of the Jetpack plugin:
    https://www.mydomain.com/wp-content/plugins/jetpack/modules/subsriptions/subscriptions.css

    So I did copy the code inside subscriptions.css and I pasted it between <style type="text/css"> and <style> tags in the head section (header.php), then I deleted the subscriptions.css file.

    The internal CSS code that I’ve added to header.php works fine.

    THE PROBLEM:

    Ine the phph file of the Jetpack plugin, there is a line of PHP code that calls for the CSS file that I’ve deleted (subscriptions.css) like so:
    wp_register_style( 'jetpack-subscriptions', plugins_url( 'subscriptions/subscriptions.css', __FILE__ ) );

    I need to replace the subscriptions/subscriptions.css with a link to my <style type="text/css"> that I’ve added to header.php

    Tell me how please … Thank You

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hopefully you’re using a child theme because if not, any updates will overwrite your edited header file and you’ll have to redo your work.

    You might be better off employing a plugin such as:

    https://www.ads-software.com/plugins/autoptimize/

    I need to replace the subscriptions/subscriptions.css with a link to my <style type=”text/css”> that I’ve added to header.php

    No you don’t. Embedded (not inlined) CSS is already loaded in the page, so you don’t need to link anything. Your plugin will still try and load its stylesheet though, so you may want to de-regsiter the style.

    https://codex.www.ads-software.com/Function_Reference/wp_deregister_style

    I’m unsure how the page load time will be effected by the plugin registering its style then you de-registering later on.

    Thread Starter Aymen

    (@aymen1210)

    Thank you WPRANGER for taking time to answer !

    I’m not so good using PHP functions.
    The page load time get affected (according to Google Page Speed and GTMETRIX), but it’s okay, I can get over that if it’s not a very important part of speed optimization.

    Thank’s for suggesting the plugin, but just in case that I’ve installed a lot of other usefull ( very usefull) plugins that I don’t want to surcharge my site using another one. But If you do insist on installing it as I can really profite from, then I’m READY!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link to an internal CSS using PHP’ is closed to new replies.