Home » Wordpress » jQuery errors “x.ready.promise is not a function” and “Modernizr.prefixed is not a function” / jQuery.noConflict

jQuery errors “x.ready.promise is not a function” and “Modernizr.prefixed is not a function” / jQuery.noConflict

Posted by: admin November 30, 2017 Leave a comment

Questions:

When i use jQuery (1.10.2) with jQuery.noConflict(); My scripts give errors like:
TypeError: $ is not a function for b.e. $(window).load(function(){ or $(document).ready(function() {
When i turn noConflict off i got these errors: “x.ready.promise is not a function” and “Modernizr.prefixed is not a function

The first error i understand? Who can explain the error with noConflict off? And tell me how to fix this.

I try to add:

    $.Deferred(function( defer ) {
    $( defer.resolve );
    $.ready.promise = defer.promise;
});

As suggest here: http://bugs.jquery.com/ticket/12946

I came across this problem when upgrading a website to WordPress 3.6

Answers:

replace $ with jQuery if you have small amout of scripts..
or wrap them in:

    (function ($, window, document) { //code }(jQuery, window, document));

or

    jQuery(document).ready(function() { //code });

or

    (function(window, undefined) {
    'use strict';
    //code
    })(this);