Blog on hold: This blog is currently on hold. Please visit blog.keranmckenzie.com for new blog posts
Post Pic

Quick WordPress Conflict Tip

A quick tip that might just help resolve conflicts between different plugins that you use on Wordpress.

Here’s a quick tip I just found to resolve potential issues on blogs – specifically WordPress, but I’m told this trick works anywhere you are loading multiple Javascript frameworks.

Warning: I’m no javascript expert, I’m a hack. I’ll tinker with things, hunt online, try things – if they work, cool. If not .. well I usually move on.

One of the beauties of WordPress is the ability to turn on and off plugins easily. You can find new plugins for your site so simply and without knowing any code you can get new features running. However, there is no standard for wordpress plugins. Developers use whatever code, libraries and resources they want too.

This means you could have one plugin using jQuery 1.4.1 and another using jQuery 1.6.2, another using Prototype, another MooTools etc.

The issue with this (as I found out recently) is these can cause conflicts between each other. It seems quite common that Prototype and jQuery will conflict. This is something that happened to me after installing the fantastic LightView Plus plugin on my wife’s blog BurntMuffin.com recently.

The plugin failed to work – I whipped open Chrome’s Developer console and found a strange error:

Object # has no method ‘dispatchEvent’

After a bit of hunting around I found this jquery.noconflict option on a forum – related to the forum btw, not to WordPress.

I thought I’d give it a shot. Now this HAS to load after you load jQuery – so I figured why not slap it on the bottom of the page:
<script ="text/javascript">
jQuery.noConflict();
</script>

Badda bing .. no more error & the plugin works as expected.

Again, I can’t say it’ll work in every instance – but it worked for me.

Support Studiowhiz.com

One Response

[...] This post was mentioned on Twitter by Larry King, Keran McKenzie. Keran McKenzie said: New blog post: A quick fix for resolving javascript conflicts in WordPress http://bit.ly/bshiPZ (Please RT) [...]