Forums

wp_register_script and wp_enqueue_script (5 posts)

  1. spstieng
    Member
    Posted 8 months ago #

    I want to add scripts like jQuery, scriptaculous etc.

    In order not to double register a script, I would like to use wp_register_script and wp_enqueue_script.

    But how do I use these?
    From what I can read, I have to put them inside functions.
    But I'm not making any plugins or such.
    I would like to add them in the header, below wp_head().

    But when I add it there, I don't see any change in the source code.

  2. MichaelH
    moderator
    Posted 8 months ago #

    At least I should point you to so you can understand what will happen with http://codex.wordpress.org/Version_2.8:
    Lester Chan's Loading Javascript in Footer blog and Andrew Ozz's Script Loader Updates blog

  3. spstieng
    Member
    Posted 8 months ago #

    Hmm... ok, thanks :)

  4. demetris
    Member
    Posted 8 months ago #

    spstieng, to do that in the way you want, which, I think, is the right way, you have to:

    1. Add the function to your functions.php file OR

    2. Make a plugin just for that: to enqueue the script

    For the scripts you mention, I think that enqueuing is enough, that is:

    wp_enqueue_script('jquery');

    For the difference between registering and enqueuing, see this recent thread in wp-hackers:

    http://groups.google.com/group/wp-hackers/browse_thread/thread/5a14b1c37ebad6d7

    (Scroll down to the 5th or 6th message, where the subject changes to exactly this difference.)

  5. spstieng
    Member
    Posted 7 months ago #

    Thanks Demetris!

    I've been thinking down the same path as you :)

Reply

You must log in to post.

About this Topic

Tags

No tags yet.