• Hi:

    My understanding is that WordPress “includes” or comes with several javascript libraries.

    When I create my own themes, do I need to do something to “enable” them? Or are they automatically included?

    In the book “Beginning WordPress 3.0” the author provides some code to “add the built-in JQuery and UI core libraries to your theme” but she doesn’t say where to put it. In the header.php? In the functions.php? (I’m guessing the header.php.)
    I checked the twentyten header and functions and don’t find any similar code in those.

    Her code is:
    <?php function add_jquery() {
    wp_enqueue_script('jquery');
    wp_enqueue_script(jquery-ui-core');
    }
    add_action('wp_head', 'add_jquery');
    ?>

    I haven’t done anything to add libraries to sites I’ve built with my own themes so far and plugins work, etc.

    What’s the deal with this?

    Thanks!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator t-p

    (@t-p)

    Thread Starter vytaulla51

    (@vytaulla51)

    Thank you for responding.

    The links, though helpful, don’t answer my central question.

    What I want to know is, do I HAVE to in some way “include” javascript/jquery libraries just on principle? I guess I’m comparing this to sidebars: to widgetize sidebars you have to put code in the functions.php to “enable” them.

    I’m understanding that, if I want to include some specific chunk of javascript on a page or post (that isn’t packaged as part of a plugin) I should include it properly using the wp_enqueue script. But that refers to the specific, particular script, right?

    That’s what I want to know. Do I need to add code somewhere to my theme so that plugins/widgets will work? Or do they all come with the code they need?

    Or do they automatically access the libraries that “come” with WP?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Javascript Libraries – do I need to do something to include?’ is closed to new replies.