WordPress and Prototype

Lots of people have searching about wordpress and prototype.js and have been lading at my post about Alex King’s Share This plugin and prototype.js. At the time I made that post, I wasn’t aware of the wp_enueque_script() function in WordPress 2.1.

Making use of wp_enqueue_script will ensure that your script is only loaded once. It’s really handy, hopefully everyone that uses prototype in their theme or plugin will start using wp_enqueue_script to load the prototype.js file. To load prototype, you’d use wp_enqueue_script like so:

<?php wp_enqueue_script('prototype'); ?>

Prototype isn’t the only script that can be loaded with wp_enqueue_script. Take a look in wp-includes/script-loader.php to see some of the other scripts that wp_enqueue_script can load by default.

You might like these posts too::

  1. Make Alex King’s Share This Plugin Play Nice With Unwakeable
  2. WordPress Plugin: Thumbnail Viewer 1.0
  3. WordPress Plugin: Digg This Reloaded
  4. WordPress 2.1 Beta 2
  5. Unwakeable Status: Version Bump

One Response to WordPress and Prototype

  1. Dean says:

    Thanks Tyler, I wasn’t aware of that either.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>