Fixing Fancybox for WordPress

So it would appear the ‘Fancybox for WordPress‘ plugin hasn’t been playing nicely with jQuery for a little while.

I was finding that my scripts weren’t working and errors in the console like…

TypeError: b.browser is undefined
TypeError: jQuery(...).fancybox is not a function

A quick search gave me a bunch of results relating to Fancybox in general (the jQuery plugin) rather than specifically to the WordPress plugin, but basically the gist of the responses were that Fancybox won’t work with the latest version of jQuery (anything from something like 1.9.x) due to various incompatibilities.

Apparently Fancybox v2 works great with the latest jQuery release, but thanks to different licensing can’t be included with the Fancybox for WP plugin.

The quick fix is to load in the jQuery migrate plugin which will take care any compatibility issues. To be clear, this is a jQuery plugin, not a WordPress plugin.

Make sure it’s loaded in after jQuery, hopefully you already know you should enqueue scripts via your themes functions.php, if not, it’s something worth looking up.

jQuery migrate solved my problem, but it’s only temporary until either Fancybox for WordPress gets an update, or I switch to another lightbox plugin that will get along with the latest jQuery releases.

// Matt

Leave a Reply

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