• Resolved iamnatedunn

    (@iamnatedunn)


    Is there any way to generate “above-the-fold” styles from a css file within a theme? In my dev setup, I generate a critical.css and a non-critical.css from my local build tool. However, I have to manually copy and paste the content from critical.css into the “Inline and Defer CSS?” text box after each time I make style changes. And obviously I have to continue to do this even after I deploy to my staging/production sites.

    Is there any work-around for this, or is this something that is potentially in the roadmap for development?

    Thanks for the help and to Frank Goossens for developing this plugin thus far.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Frank Goossens

    (@futtta)

    so if I understand you have critical.css (as generated by your local build tool) and you want to use that one?

    in that case you can tell AO to use that using the API;

    add_filter('autoptimize_filter_css_defer_inline','nate_defer_inline',10,1);
    function nate_defer_inline($inlined){
        return file_get_contents("path/to/critical.css");
    }
    Thread Starter iamnatedunn

    (@iamnatedunn)

    Ah, thanks. I wasn’t aware that this was an option with the API. Worked perfectly. Though I did remove the $inlined since I don’t think I need to pass that.

    Plugin Author Frank Goossens

    (@futtta)

    in the code as above, you can indeed remove the $inlined as input param., but if you’d ever want to expand on that code, taking the critical css entered on the settings page into account somehow, you’d need that. so it’s there as a kind reminder of its existence, really ??

    if ok, can you set this to “resolved” (I can’t seem to do that any more since the www.ads-software.com plugin overhaul of last week)?

    Thread Starter iamnatedunn

    (@iamnatedunn)

    Good reminder. I’ve set this to “resolved”. Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Generate “above-the-fold” from file’ is closed to new replies.