WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] Remove Additional Call for jQuery (5 posts)

  1. Maximus Saint
    Member
    Posted 2 years ago #

    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/

  2. RavanH
    Member
    Plugin Author

    Posted 2 years ago #

    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 ;)

  3. Maximus Saint
    Member
    Posted 2 years ago #

    I see, Thank you.

  4. Maximus Saint
    Member
    Posted 2 years ago #

    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');
  5. Maximus Saint
    Member
    Posted 2 years ago #

    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');

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic