Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    At the moment I am deferring my jQuery 1.11.1, and loading it in the bottom of the page. removing deferring and moving it to the header solves the problems

    If you want to move jQuery to the footer of your site, you’ll also need to make sure all the other libraries relying on jQuery are moved properly. That includes some Jetpack resources, but also other plugins and your theme (e.g. wp-content/themes/anew/js/jquery.flexslider.min.js).

    If each resource is enqueued properly and mentions the dependency with jQuery, you should be able to load everything in the footer by dequeuing jQuery, and enqueuing it again in the footer.

    Note that this also means that some things might look funky on your site until jQuery and related libraries load properly.

    If you continue to experience issues, could you check and see what js files are loaded before jQuery on your site?

    I’m no jQuery wizard, but shouldn’t you use .ready() instead of .on( ‘ready post-load’ ?

    I’m not jQuery expert either, but that seems like a good idea. I took note of your suggestion here:
    https://github.com/Automattic/jetpack/issues/1392

    I’m noticing this as well. I’d prefer to load jQuery in footer, can Jetpack scripts be called after all the enqueued scripts from the theme’s functions file? Seems that would solve it

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    @szyam If your theme handles dependencies to jQuery properly, that shouldn’t be a problem. If you dequeue jQuery and enqueue it again, WordPress will make sure that all files depending on jQuery are enqueued after jQuery is added.

    I’ve just come across this issue too, in a theme that properly dequeues and enqueues jQuery in the footer.

    It appears that several *inline* scripts are the culprit… see here: https://github.com/Automattic/jetpack/blob/master/modules/sharedaddy/sharing-sources.php#L194

    I have not dug around enough to determine whether js_dialog() properly defers loading until after jQuery is included, but it looks like not.

    There are several other inline blocks of Javascript peppered throughout that file based on the various sharing services selected and I wonder if they cause the same issues (I’m currently only using Twitter and Facebook).
    ——————————————

    After writing all of that I checked the Github repo and found this gem: https://github.com/Automattic/jetpack/issues/1223

    Changing that line in sharing-service.php to add_action( 'wp_footer', 'sharing_add_footer', 25 ); does solve my issue, but it’s not a permanent fix.

    Plugin Contributor Ryan C.

    (@ryancowles)

    Thanks for the report! I’m glad to hear that you found a temporary solution.

    Since the Issue is already reported on GitHub, I would recommend following its progress there. You can comment on the Issue if you’d like, or even submit a Pull Request. Otherwise, our developers will take a look as soon as they can.

    In case people come across this thread: The issue should be fixed (at least temporarily) in the next Jetpack release. See: https://github.com/Automattic/jetpack/pull/1666

    This actually looks like a jQuery version collision, since on() was deprecated from jQuery 1.6 or 1.7, and since then live() is used. Can be solved by checking the function availability – or possibly even with bind() or a document.ready-variant that some of you have mentioned.

    We have a Magento-plugin at my work that does this since plugins are delivered with different jQuery-versions and sometimes, they collide in compatibility. It goes like something like this:

    if (typeof jQuery.on() === "function") {
    // code stuff
    } elseif (typeof jQuery.live() === "function") {
    // code stuff
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘problem with .on( 'ready post-load' in the sharing part’ is closed to new replies.