• Resolved kocakserdar7

    (@kocakserdar7)


    Hi,

    I have two question,

    1- jquery.js is excluded from minify. I want to embed jquery.js from <head> to after <body>. But not embed before </body>. Because if I embed it to the footer (</body>) it causes jquery issues.

    Google recommend migrate scripts from head to body. So embed jquery from head to after <body> can improve pagespeed? What do you think about that?

    Thank you,
    Best regards.

    • This topic was modified 6 years, 3 months ago by kocakserdar7.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Raul P.

    (@alignak)

    Hi,

    I’m a bit busy, so apologies for the short reply.

    Deferring jquery, has the same effect of moving it to the footer, so there’s no need to manually move it down in the code. Defer will downloaded it after the page load.

    The issue with that, with either moving it to the footer or using defer, is that you may have other inlined javascript code on the page that requires jQuery to run (this is very common actually).

    When that happens, you will see an “undefined” error on google chrome console log.

    That’s the reason why defer for insights exist, so it defers them for the bots but not for normal users.

    If You defer jQuery library, or load asynchronously, You must be sure, that everyone script is adapted to work asynchronously.

    • This reply was modified 6 years, 3 months ago by betagoo.
    Plugin Author Raul P.

    (@alignak)

    Google recommend migrate scripts from head to body. So embed jquery from head to after <body> can improve pagespeed? What do you think about that?

    Sorry, I missed your point…

    You can’t!
    There is no hook on wordpress to move the header scripts to right after the body… you would have to dequeue jquery and then manually hardcode it to the theme… however, this will break other things because wordpress has dependencies.

    Many plugins load their scripts “depending” on jquery being enqueued and detected. If you remove it, those scripts wouldn’t detect it being enqueued and they would not enqueue their own scripts.

    You could use the preload feature and see if it makes a difference.
    I add some success on pagespeed, having jquery render blocking and then having it with a preload header, which ended up downloading it before the browser had time to reach the html section where jquery is called.

    But in short, google recommends it… sure, but the sites have to be made from scratch with that in mind. WordPress is a set of moving parts, themes, plugins, etc… it needs render blocking sometimes, in order to work… unless you are a developer and manually edit each theme and plugin to allow it to be deferred.

    Thread Starter kocakserdar7

    (@kocakserdar7)

    @alignak Once again, Thank you for detailed information ??

    Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Jquery’ is closed to new replies.