25

I am getting below error when I look in the console:

jQuery.easing[jQuery.easing.def] is not a function

I am trying to make a slider on WordPress. I am working on a localhost so I can't exactly show whats up. However, when the slider is just in an HTML file outside of WordPress it works. When in WordPress, it is giving me that error. Any insight into what the problem could be will be greatly appreciated.

Mario Boss
  • 1,784
  • 3
  • 20
  • 43
Eric Goncalves
  • 5,253
  • 4
  • 35
  • 59
  • 8
    Post your code. We can't debug invisible code. – Blender Jul 18 '12 at 01:50
  • 1
    This blog post help me, now it works for me : [http://www.gilluminate.com/2011/06/06/jquery-easingjquery-easing-def-is-not-a-function/](http://www.gilluminate.com/2011/06/06/jquery-easingjquery-easing-def-is-not-a-function/) – OlivierG Nov 22 '12 at 11:15

9 Answers9

54

To save everyone some time. Open your Jquery easing plugin file and wrap the code inside:

$(document).ready(function() {
  Code goes here...
});
coletrain
  • 2,809
  • 35
  • 43
  • 1
    I only get the issue when using it with CommonJS/browserify but this solution fixed it. – texelate Jul 18 '16 at 12:01
  • "Open your Jquery easing plugin file" -- where is the location of that file? does it come with wordpress or is it something assumed to be manually installed? thanks :) – aequalsb Jul 22 '16 at 22:34
  • @aequalsb In inspect element, where the error is printed, hover with your mouse on the filename and it will show you the full path. – Lemures Jun 28 '18 at 08:59
  • 1
    Does anyone know why when I do `$(document)` it works, but if I do `jQuery(document)` it does not? – Lemures Jun 28 '18 at 09:00
  • @Lemures how can i see the OP's error when the code is not presented nor a URL to view the error... i think you misunderstood... i was suggesting action for the OP – aequalsb Jun 28 '18 at 18:53
25

Please check that whether you are loading jQuery more than once. If you have inserted in the footer manually, try removing it.

Ijas Ameenudeen
  • 9,069
  • 3
  • 41
  • 54
  • This was it for me! A plugin from october cms was injecting its own jquery alongside the one I had included myself. – jahackbeth Nov 08 '19 at 21:17
21

The problem is

swing: function (x, t, b, c, d) {
    return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
}

jQuery in this function could not be equal to the jQuery, where jQuery.extend( jQuery.easing, has been applied.

  1. replace jQuery with $
  2. wrap code with

    (function($, undefined) {
      ...
    }) (jQuery);
    
puchu
  • 3,294
  • 6
  • 38
  • 62
7

did you import the jQuery easing plugin? something like

  <script src="http://code.jquery.com/jquery.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>

in your page?

Rishi Kulshreshtha
  • 1,748
  • 1
  • 24
  • 35
pna
  • 5,651
  • 3
  • 22
  • 37
5
if(typeof jQuery.easing[jQuery.easing.def] == 'function'){
    return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
}

try this code on swing() function on easing.js

Sanhosh john
  • 103
  • 2
  • 8
4

Put jquery.easing.1.3.js to head tag before using plugin or use document.ready

nixis
  • 510
  • 5
  • 10
3

Don't declare the script on the header, call it through jQuery's .getScript() function when the document is fully loaded.

Example:

<script>
$( document ).ready(function() {
    $.getScript('path_to_script/easing_script_name.js');
});
</script>

The error is due to that jQuery is called before easing script it's fully loaded.

Luis
  • 280
  • 3
  • 11
2

Are you importing the jQuery easing plugin? Or anything higher than 1.7.2?

Then just remove that and use this:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
isherwood
  • 58,414
  • 16
  • 114
  • 157
shiny
  • 124
  • 6
0

It may happen if you are calling the WordPress slider plugin's javascript before jQuery or jQuery UI call.

Does it resolve this way?

<script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.4/umd/popper.min.js"></script>
    <script type="text/javascript"
        src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="/wordpress-slider-plugin.js"></script>
Ritam Das
  • 183
  • 1
  • 3
  • 12