• Resolved wildmice

    (@wildmice)


    It’s nice to see that this plugin is doing a thorough job of gathering up the inline css and adding it to its single combined css file. However, i have a case where, for performance reasons, i am including certain structural css inline. It would be nice to have a way of preserving inline css when that is important. Perhaps an option on the plugin settings, or some way of marking specific inline css so the plugin can get the message to leave it where it is.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi wildmice,

    You can exclude all inline CSS from aggregation via:

    add_filter('autoptimize_css_include_inline','my_ao_css_include_inline',10,1);
    function my_ao_css_include_inline() {
            return false;
    	}

    Or, enter the CSS selector for the specific CSS you wish to exclude from aggregation into the “Exclude CSS from Autoptimize” field in the AO dashboard.

    Best,
    AJ

    …forgot to mention you could also wrap the CSS you wish to exclude in <!--noptimize--> tags.

    E.g.

    <!--noptimize--><style type="text/css">
         #site-title-description {
    position: absolute !important
    clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
    clip: rect(1px, 1px, 1px, 1px);
         }
    </style><!--/noptimize-->

    Be well,
    AJ

    Thread Starter wildmice

    (@wildmice)

    Thanks AJ. The noptimize is what i ended up using.

    The more i use this plugin the more i’m impressed. At the outset i wasn’t expecting such depth of detail so didn’t even look for some of these features.

    What really kind of blew me away was when i tried the option to defer CSS loading – loading it via Javascript – and despite the complexity of the page it actually worked (aside from the flash of unstyled content).

    Frank has created a very special thing with AO and there’s actually very little one can’t do when factoring in the API. The icing on the proverbial cake is, of course, Frank’s tireless dedication to his creation. It sure doesn’t hurt that he’s just a great guy.

    the flash of unstyled content

    That too can be fixed with AO, my friend. ?? You just need to find the CSS critical to rendering your above-the-fold content and enter it into the text field provided in the UI.

    Be well,
    AJ

    Thread Starter wildmice

    (@wildmice)

    Lol, that is where i get off the big G’s bandwagon. I am building sites for *all* devices, not just mobile. On some screens *all* the content is above the fold, on phones hardly any. “Above the fold” is a futile exercise IMO.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sometimes inline CSS should stay inline’ is closed to new replies.