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

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.

Related posts

Leave a Reply

9 comments

  1. 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);
      
  2. 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?

  3. 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

  4. 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.

  5. 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>
    
  6. 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>