• Resolved kduadmn

    (@kduadmn)


    I am trying to load “AO above the fold css” after the yoast meta tags but failed every time. Could you please help me how to inject the critical css after yoast tags in source code?
    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    you can do so using this code snippet;

    add_filter('autoptimize_filter_css_replacetag','kduadmn_css_replacetag',10,1);
    function kduadmn_css_replacetag($replacetag) {
    	return array("</head>","before");
    	}

    hope this helps,
    frank

    Thread Starter kduadmn

    (@kduadmn)

    Is it not possible to inject the css right after the yoast meta tags?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, AO doesn’t know what Yoast’s meta tags are, but you can change the code snippet according to your needs ??

    some explanations;
    -> the first argument is an HTML tag (which needs to be present, obviously, which is why by default AO uses <title> and the example uses </head>).
    -> the 2nd argument is either before or after, indicating if the CSS has to come before of after the tag.
    -> the 2nd variable can also be replace, in which case you would add something (e.g. <!--ao-css-replacetag-->) to the head (in your theme) and then use that tag as first argument and replace as the 2nd one.

    Thread Starter kduadmn

    (@kduadmn)

    Thanks for the quick reply.

    Ok, I want to use the replace variable but don’t know how to insert <!–ao-css-replacetag–> at the desired location within <head></head> because all the codes and tags by plugins are inserted automatically within the <head></head> section using wp_head.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    in that case you’ll have to find a tag in your sites head which always occurs and use after/ before?

    Thread Starter kduadmn

    (@kduadmn)

    Ok @optimizingmatters, thank you for the valuable help and explanations, I really appreciate your knowledge and plugin support.

    Best regards!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome, feel free to leave a review of the plugin and support here! ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Above the fold css in source code’ is closed to new replies.