• Resolved steveraven

    (@steveraven)


    I keep on coming back to this plugin, as I’m sure there must be a setting I’ve missed.

    At the moment, I’ve got Async Javascript handling the javascript issues, with Autoptimise handling the rest, css and html minification, but it would be really nice to lump everything into the same plugin.

    The reason I’m using this method, is as I said before, the whole website hangs when using Autoptimise to handle the javascript – and I’m not really bothered about speed tests from another website – its plainly obvious that the website is hanging (running slowly).

    In one last vain effort – what settings should be used – though I think I’ve tried them all!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter steveraven

    (@steveraven)

    Well bugger me, I think I found it!

    The point is to NOT enable any of the in-head or inline options, instead of choosing one or the other.

    Add a little catch wrapping and all looks good to go!

    Plugin Author Frank Goossens

    (@futtta)

    great Steve!

    fyi; the default JS settings are not to force JS in head (as that means it is not deferred, which can slow initial HTML rendering down) and not to aggregate inline JS (as that can lead to cache size issues if you have frequently changing JS variables), but for CSS the default is to aggregate the inline code (as the risk of rapidly changing inline CSS is a lot smaller).

    now to be clear; if JS is not forced in head, that does mean it executes later and it might be that’s the slowdown you noticed (although if I remember correctly your site is not that JS-heavy). so “force in head” could slow HTML rendering down but can speed JS rendering-triggered rendering up. an additional alternative would be to keep JS out of head, but to remove the “defer”-flag (or replace it by “async”) with a small code snippet. let me know if you’d like to try that out as well!

    frank

    Thread Starter steveraven

    (@steveraven)

    Hi Frank,

    Well I only have a jquery file in there, slowing my website up at the moment – but what the heck – lets try the code snippet!

    Any ideas on how browser caching can be enabled for Google Analytics, or is that out of the scope for this plugin?

    • This reply was modified 7 years, 11 months ago by steveraven.
    Plugin Author Frank Goossens

    (@futtta)

    lets try the code snippet!

    ok, to switch to async use

    
    add_filter('autoptimize_filter_js_defer','steve_override_defer',10,1);
    function steve_override_defer($defer) {
    	return "async ";
    }

    and to simply remove the defer-flag you can use return " "; on the 3rd line

    Any ideas on how browser caching can be enabled for Google Analytics, or is that out of the scope for this plugin?

    that indeed is out of AO’s scope.

    frank

    Thread Starter steveraven

    (@steveraven)

    Not meaning to sound a bit dim here, but what do I put in instead of ‘steve’?

    Would it be ‘mywebsiteaddress_override_defer’?

    Plugin Author Frank Goossens

    (@futtta)

    no, you can leave as is ??

    Thread Starter steveraven

    (@steveraven)

    No, that snippet is dragging my website back again.

    I think we’ll leave it as is.

    Thread Starter steveraven

    (@steveraven)

    And for anyone that might be interested – to remove Google Analytics from being render blocking –

    Remove any instances of GA from Yoast, AIOSEO, Monsterinsights and the like, as well as any theme dependent tracking code, as multiple instances will cause multiple problems.

    Then download the Google Analytics plugin from the repository, and make sure that you’re running it in the footer.

    Activate and enjoy!

    Moderator chriscct7

    (@chriscct7)

    Google Analytics is supposed to fire in the header not in the footer, per Google’s best practices guidelines. Firing it in the footer, even when using the asyc version of the GA script, will cause issues with event tracking.

    -Chris

    Plugin Author Frank Goossens

    (@futtta)

    I think we’ll leave it as is.

    seems like the best approach, yeah ??

    Thread Starter steveraven

    (@steveraven)

    Thanks for all your help!

    Google Analytics is supposed to fire in the header not in the footer, per Google’s best practices guidelines.

    When I use Clicky, or Statcounter, or any other tracking device, they insist that it makes no difference whether their code is in the header or footer.

    When Google start playing fair and their own analytics code stops buggering up my site speed, it can go back in the header.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Well, I keep on Trying…’ is closed to new replies.