Search code examples
javascriptjqueryajaxwordpressvisual-composer

Visual Composer / Jquery Animations not working Debug Error


I have visual composer installed on a wordpress site. For some reason when i isert and image or any element and apply the animation from inside visual composer, the page goes blank and nothing shows, no animations, nothing.

After contacting the plugin developer they said another plugin is conflicting but i have just 1 other plugin installed, jetpack. I have uinstalled that and the problem persists.

Using the debug tool i get the following errors. any ideas?

Uncaught TypeError: a.indexOf is not a function at r.fn.init.r.fn.load (jquery.min.js?ver=3.1.1:4) at waypoints.min.js?ver=5.0.1:8 at waypoints.min.js?ver=5.0.1:8 at waypoints.min.js?ver=5.0.1:8 at waypoints.min.js?ver=5.0.1:8

Uncaught TypeError: f.getClientRects is not a function at r.fn.init.offset (https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js?ver=3.1.1:4:20376) at t.refresh (http://####/wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:2072) at t. (http://#####/wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:6130) at Function.each (https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js?ver=3.1.1:2:2865) at refresh (http:#####/wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:6100) at Function.n.(anonymous function) [as waypoints] (http://###wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:7638) at r.fn.init.init (http://####/wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:4817) at r.fn.init.n.fn.(anonymous function) [as waypoint] (http://######/wp-content/plugins/js_composer/assets/lib/waypoints/waypoints.min.js?ver=5.0.1:8:5712) at function.window.vc_waypoints.window.vc_waypoints (http://####/wp-content/plugins/js_composer/assets/js/dist/js_composer_front.min.js?ver=5.0.1:1:7243)


Solution

  • By default, the latest version of WordPress uses jQuery version 1.12.4 but your site seems to be calling jQuery 3.1.1 via Google's CDN. It's possible that Visual Composer isn't compatible with jQuery 3 yet.

    If this is the only plugin on the site, then it's likely the theme calling this jQuery version. And if it's properly coded, you should be able to find a wp_register_script or wp_enqueue_script function that is overriding the jQuery version. If you replace that with wp_enqueue_script( 'jquery' );, you'll load up WordPress' jQuery which may solve the issue.

    Three notes:

    1. The theme may have replaced jQuery by using wp_deregister_script. You'll need to comment that out too.
    2. Changing the jQuery version may break javascript coming from your theme if that js needs jQuery version 3 so look for issues on that end as well.
    3. When you update your theme, it will revert this change. So you should consider doing this through a child theme to preserve your changes across updates.