Support » Plugin: Easy FancyBox - WordPress Lightbox Plugin » [Plugin: Easy FancyBox] Remove Additional Call for jQuery

  • Resolved Anonymous User 4104441

    (@anonymized-4104441)


    Hi, I’m having really hard times removing easy-fancybox’s call for jquery:
    i.imgur.com/ec0rk.png
    as i understand, the developer of this plugin, for some reason decided to include a call for local jQuery library, which ruins my day since i’m calling jQuery from CDN directly in my template.

    I tried to find appropriate code in easy-fancybox.php but couldn’t.

    Please advise how can i remove this additional call.

    Thanks

    http://wordpress.org/extend/plugins/easy-fancybox/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    I advise you to NOT hardcode script calls in your theme. WordPress has a dedicated routine for that: https://codex.wordpress.org/Function_Reference/wp_enqueue_script

    This is the recommended way to include script files, even for those from CDN and the only way to avoid conflicts with plugins that need jQuery or other libraries.

    By far the easiest way to get jQuery from an external CDN is to remove that hardcoded line and install the plugin http://wordpress.org/extend/plugins/use-google-libraries/ or any of the other ones that provide this function. These plugins will make ANY library (not only jQuery) that will be needed by any other plugin now and in the future be taken from Google’s CDN. So you’re safe for the future as well 😉

    Thread Starter Anonymous User 4104441

    (@anonymized-4104441)

    I see, Thank you.

    Thread Starter Anonymous User 4104441

    (@anonymized-4104441)

    To those who doesn’t want to waste time by reading manuals, place this into your functions.php:

    // Load jQuery from CDN
    function my_scripts_method() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
        wp_enqueue_script( 'jquery' );
    }
    add_action('wp_enqueue_scripts', 'my_scripts_method');

    Thread Starter Anonymous User 4104441

    (@anonymized-4104441)

    and if you want to include your own script, use this code, just change the path and name for .JS:

    // Load my Script
    function myScript() {
       wp_enqueue_script('jquery');
       wp_enqueue_script('zion', '/js/zion.js', array('jquery'));
    }
    add_action('init', 'myScript');

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Easy FancyBox] Remove Additional Call for jQuery’ is closed to new replies.