Blog

Recent Blog Posts

Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed or Subscribe to Email update. You will find all kinds of things about technology here!

OpenAjax Hub 1.0 Spec Released

The OpenAjax Hub is a set of standard JavaScript functionality that ensures that multiple Ajax libraries can be used within the same web page. This week the final 1.0 specification was approved by the OpenAjax members. This is the first specification to come out of The OpenAjax Alliance, which is a major milestone towards standardization of Ajax.

If you enjoyed this post, make sure you subscribe to my RSS feed!


Loading custom Javascript Libraries in Wordpress Themes with wp_enqueue_script()

Since reading Nick’s entry on Loading Javascript Libraries in Wordpress Plugins, I have decided to use the same techniques to get my custom Theme to load JavaScript using wp_enqueue_script().

There is two reasons why I wanted to load my custom JavaScript libraries:

  1. Default jQuery library included with the latest version of WordPress is not up-to-date
  2. My custom code does not work with the default version included with this release WordPress

As this is a custom theme I have a functions.php where I have defined all my custom functions. So to load the custom JavaScript.

< ? php
function my_add_js_libs() {
//Add the jquery framework to the header
//wp_enqueue_script('jquery'); // default jquery is not up-to-date
//wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false );
wp_enqueue_script('my_jquery', $src = '/wp-content/themes/[mythemename]/js/jquery-1.2.1.pack.js’, $deps = array(), $ver = ‘1.2.1′ );
wp_enqueue_script(’my_core_js’, $src = ‘/wp-content/themes/[mythemename]/js/core.js’, $deps = array(’my_jquery’));
}
? >

then make a call to the function in the header.php just before the wp_head();

< ? php
my_add_js_libs();
wp_head();
? >

This should now load the custom JavaScript Libraries required for your themes in the sequence that WordPress decides.

If you enjoyed this post, make sure you subscribe to my RSS feed!


Feedback Form