WordPress.org

Ready to get started?Download WordPress

Forums

Use Google Libraries
[resolved] How do I load a JS library with this plugin? [noob question] (2 posts)

  1. makimaki
    Member
    Posted 2 years ago #

    I am just getting back to JQuery and wordpress. Been trying to load JQuery UI to my WordPress site but can't seem to.

    I know they need to be in the head tag and all... just not know how to do it with this plugin.

    With wordpress, I add some code on functions.php template to enqueue it. This is what I have on my template

    function myjquery() {
    if (!is_admin()) {
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui');

    // load a JS file from my theme: js/theme.js
    wp_enqueue_script('my_script', get_bloginfo('template_url') . '/magick.js');

    }
    }
    add_action('init', 'myjquery');

    This is all the scripts I am loading but don't see jquery-ui on the website's frontend. I see the main jquery file though and even my custom JS file.

    Am I even close or is this not how you do it with this plugin. please help... preferably with the exact code. but any hint would help

    http://wordpress.org/extend/plugins/use-google-libraries/

  2. Jason Penney
    Member
    Plugin Author

    Posted 2 years ago #

    Loading scripts as you've outlined here should behave exactly the same with or without this plugin loaded (with the exception of where it's loading the scripts from).

    If your script uses jquery-ui then all you should let the script loader handle the dependencies rather than enqueueing them by hand. Something like this:

    wp_enqueue_script('my_script',
                       get_bloginfo('template_url') . '/magick.js',
                       array('jquery-ui'));

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic