jQuery.easing[jQuery.easing.def] is not a function
Asked Answered
C

9

26

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.

Curriculum answered 18/7, 2012 at 1:41 Comment(2)
Post your code. We can't debug invisible code.Mchale
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/Fichtean
N
54

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

$(document).ready(function() {
  Code goes here...
});
Nadabb answered 4/5, 2013 at 2:44 Comment(5)
I only get the issue when using it with CommonJS/browserify but this solution fixed it.Miller
"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 :)Ishtar
@Ishtar In inspect element, where the error is printed, hover with your mouse on the filename and it will show you the full path.Determinant
Does anyone know why when I do $(document) it works, but if I do jQuery(document) it does not?Determinant
@Determinant 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 OPIshtar
C
27

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

Cafard answered 20/9, 2012 at 16:13 Comment(1)
This was it for me! A plugin from october cms was injecting its own jquery alongside the one I had included myself.Kirkpatrick
P
22

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);
    
Phosphorism answered 2/10, 2014 at 14:6 Comment(0)
R
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?

Resent answered 18/7, 2012 at 2:3 Comment(3)
Yeah, when I add that I get an ReferenceError: jQuery is not defined then the original errorCurriculum
then you also need to add the jQuery itself, just before the easing plugin... i've edit the answer!Resent
jQuery is not defined is gone, but the original error still remainsCurriculum
A
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

Ailssa answered 15/9, 2015 at 10:25 Comment(0)
C
4

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

Choctaw answered 17/7, 2013 at 6:31 Comment(0)
L
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.

Laryngitis answered 17/11, 2015 at 3:51 Comment(0)
M
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>
Mourant answered 23/1, 2014 at 12:15 Comment(0)
V
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>
Vanburen answered 8/10, 2018 at 9:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.