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.

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