Support » Plugin: Autoptimize » Activated “defer and inline” but would like to exclude home page.

  • Resolved AoxoA

    (@aoxoa)


    I’d like to exclude my home page from “inline and defer css”. My “above the fold CSS” works good for everything except the home page.

    I cobbled together the following code. If I am on the right track, what will I use for the {return “what do I put here to stop inline and defer”;}:

    add_filter('autoptimize_filter_css_defer_inline','my_ao_css_defer_inline',10,1 ); 
    function my_ao_css_defer_inline($inlined) { 		
             if (is_front_page())!==false) { 		
                   return "what do I put here to stop inline and defer";} 	
             } else { 			
                   return $inlined; 	
                    }

    Thank you for your time.

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

    (@futtta)

    easiest solution would be to put critical css specifically for your HP there 🙂

    I was testing critical css for the HP to do exactly that. However, on pagespeed it didn’t move the dial. And on GTmetrix it increased my load time (+.1), total page size (+.01mb) and request (+1). Plus, I am having issues with @media in my css. Ha, so I thought why not exclude the home page.

    Since it is not as easy as I thought, I’ll but in the css as you suggest.

    So, everything else looks ok? like using is_front_page instead of is_home?

    Dreamweaver doesn’t like something about this part of the code ==false { return At least that is when it notified me of the syntax error.

    It says “there is a syntax error. Code hinting may not work until I fix the error.”

    I tried it live and my webpage would not load.

    I put this code in my themes functions.php:

    add_filter('autoptimize_filter_css_defer_inline','my_ao_css_defer_inline',10,1 ); 
    function my_ao_css_defer_inline($inlined) { 	
    if (is_font_page())!==false { return "my minified critical css for home page";} 	} else { 			
             return $inlined; 	
                    }

    Note: in place of my minified critical css for home page I put my css within the quotes.

    Plugin Author Frank Goossens

    (@futtta)

    well, we’re well outside traditional AO support and into PHP-dev support here 😉

    but there indeed is an error;

    
    if (is_font_page())!==false { return

    should be:

    
    if (is_front_page()===true) { return

    or even just:

    
    if (is_front_page()) { return

    🙂

    Thank you for the input and amazing support. I got it with this code:

    add_filter('autoptimize_filter_css_defer_inline','my_ao_css_defer_inline',10,1);
     function my_ao_css_defer_inline($inlined) {
     if (is_front_page()) {
     return "your-home-page-css-goes-here"; // overwrite default a-t-f CSS
     } else {
     return $inlined; // use default a-t-f CSS for all other types
     }
     }

    I compiled my notes and made an in depth guide about how to target the home page with its own unique inlined CSS.

    Plugin Author Frank Goossens

    (@futtta)

    that’s a very nice in depth guide you wrote there Chris, kudo’s!! 🙂

    did you find any time to look further into that font-face problem (maybe trying the variations I mentioned in that other post)? saw your other reply just now 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Activated “defer and inline” but would like to exclude home page.’ is closed to new replies.