Title: Above the fold css in source code
Last modified: July 15, 2022

---

# Above the fold css in source code

 *  Resolved [kduadmn](https://wordpress.org/support/users/kduadmn/)
 * (@kduadmn)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830343)
 * 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](https://wordpress.org/support/users/kduadmn/)
 * (@kduadmn)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830359)
 * Is it not possible to inject the css right after the yoast meta tags?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830458)
 * 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](https://wordpress.org/support/users/kduadmn/)
 * (@kduadmn)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830537)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830597)
 * in that case you’ll have to find a tag in your sites head which always occurs
   and use after/ before?
 *  Thread Starter [kduadmn](https://wordpress.org/support/users/kduadmn/)
 * (@kduadmn)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830620)
 * Ok [@optimizingmatters](https://wordpress.org/support/users/optimizingmatters/),
   thank you for the valuable help and explanations, I really appreciate your knowledge
   and plugin support.
 * Best regards!
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830628)
 * you’re welcome, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Above the fold css in source code’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/above-the-fold-css-in-source-code/#post-15830628)
 * Status: resolved