One of the most frustrating items I’ve come across recently is that alot of WordPress plugins include their own version of jQuery or similar JavaScript library. Please Stop!!!!

What you may not realize is that WordPress comes bundled with the jQuery library and to boot they provide a simple method to not only include it in your website but to ensure that it only gets included once. Please familiarize yourself with the wp_enqueue_script function as it will make your plugins cleaner and help to mitigate conflicts with other plugins and templates.

To include jQuery, Scriptaculous, or similar libraries is a simple 2 step process.

  1. Register a method for the init hook
    This is necessary as the wp_enqueue_script should be called upon the init stage of WordPress execution.
    add_action('init', 'plugin_init');
  2. Enqueue the jQuery library
    function plugin_init() {
        wp_enqueue_script('jquery');
    }

There you have it you have now included jQuery into the website that uses your plugin.

, , , , , ,

Unfortunately Microsoft over the years has left us disappointed year after year with their web browser Internet Explorer. Yes, I know we all have had frustration with the little quirks that all browsers have but Internet Explorer has been the bane of the web developer. IE 8 like previous incarnations appears at first to be step up until you look closely and notice the issues with its animation rendering capability.

Anyhow enough rambling, Recently I came across a nifty little meta tag that IE 8 supports that tells it to render the page content as IE 7 would. Quickly and easily removing any quirks introduced to your website that are IE 8 specific. Now instead of 2 or 3 version of IE that you need to support you are back down to simply IE 7 or if you are one of the unfortunate ones, IE 6 as well.

<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">

Enjoy, and here is to hoping that for IE 9 they do a full rewrite of this web browser known as Internet Explorer

, , , ,

When developing within a large web application it may be needed to check if a JavaScript function/object exists prior to being calling. The benefits to checking if the method exists are:

  1. No JavaScript errors are Generated.
  2. if needed you can dynamically load and initialize your method or object

In most cases you won’t need to test for a function but in the rare cases that you find yourself not sure of what has been loaded into the DOM (Document Object Model) you can check by simply calling window.methodName. By wrapping it in a if statement it will let you know if the method exists.

if( window.methodname ) {
  // method exists
} else {
  // method does not exist
  function methodName() {
 
  }
}
,