• alexanderzagniotov

    (@alexanderzagniotov)


    Hello Team,

    I have a question regarding something that as a plugin developer I have been observing for a long time now.

    When I developed my plugin, I ensured that plugin JS scripts are loaded having jQuery bundled with WP as a dependency, etc:
    wp_enqueue_script('my-script', "script-location", array('jquery'), false);. I thought if WP offers me something, I better rely on it for consistency.

    Often, my plugin users turn to me with “…hey, suddenly your plugin is broken … or it does not work”. After inspecting the HTML source of their sites, I discover that other plugins and/or theme loaded jQuery again, in addition to jQuery provided by WP. One time I have seen someone’s site where jQuery has been loaded 5(!) times (3 different versions) by different plugins on top of the one provided by WP.

    As a result of that, my plugin JS breaks because JS scope gets messed up.

    My question is:
    Is there anything I can do to prevent my plugin from breaking up when other plugins load jQuery again and again?

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Jay

    (@phyrax)

    Well my first and obvious question is, have you tried running your jQuery script in no conflict mode?

    Thread Starter alexanderzagniotov

    (@alexanderzagniotov)

    Hi Jerry,

    Well no, because I don’t use the $ sign, but ‘jQuery’ instead.
    Did I miss something?

    Thread Starter alexanderzagniotov

    (@alexanderzagniotov)

    Ok, I should have to check more thoroughly, the jquery API lists proper examples

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to provide a safety net against multiple jQuery loading?’ is closed to new replies.