• brightemo

    (@brightemo)


    wp_register_script(Helper::tokenize('jquery-public'), "https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js", false, null);
    wp_enqueue_script(Helper::tokenize('jquery-public'));

    By using the name ‘jquery-public’ instead of ‘jquery’ you are causing jQuery to be loaded twice.

    We are already en-queuing the standard (included with WordPress) jQuery library (and jquery-migrate); so your plugin should not need to load another version of jQuery.

    It would be better if you didn’t wp_enqueue_script jQuery at all, and modified your scripts that require jQuery to depend on ‘jquery’ (rather than ‘jquery-public’).

    Wordpress will then only load jQuery if it hasn’t already been loaded.

    • This topic was modified 8 years ago by brightemo.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author leandrov

    (@leandrov)

    This is inaccurate you should be able to include multiple version of jquery on the same page as long as you are using jquery noConlict you should be ok https://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page
    if youre page is failing please post some screentshots if you would so we can help you better.

    Thread Starter brightemo

    (@brightemo)

    Okay so, yes, sorry, in theory you are right.

    However the problem we are having is that:

    1. jQuery (included with WordPress) is loaded: Populates global jQuery
    2. jQuery Flexslider (from a ‘WordPress Plugin A’) is loaded: Adds function to global jQuery
    3. jQuery (include with this plugin) is loaded: Overrides jQuery global
    4. ‘WordPress Plugin A’ tries to call jQuery.flexslider in <body>, but it doesn’t exist

    Example: One jQuery
    Example: Two jQuery

    Plugin Author leandrov

    (@leandrov)

    the problem is that flexslider is not using jQuery.noConflict() was they should in any case let us run some test and see if we can figure out away around this problem to help you out.

    Thread Starter brightemo

    (@brightemo)

    If this plugin needs jQuery 2 (over whatever is included in WordPress) then you could provide a local (rather than CDN) copy of jQuery 2 modified; with something like

    window.jQuery2 = jQuery.noConflict(true);

    at the end of the file. (The true flag releases the jQuery object as well as $)

    Then modify this plugin to only use jQuery2() whether directly or via aliasing

    (function($){
        $('#example').toggleClass('example');
    })(jQuery2);

    That would ensure that this plugin is compatible with as many other WordPress plugins as possible I think.

    Example

    • This reply was modified 8 years ago by brightemo.
    Plugin Author leandrov

    (@leandrov)

    We have released a new update which address this issue please update and let us know.
    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘jQuery included twice breaks other plugins/code’ is closed to new replies.