Support » Fixing WordPress » jQuery error in custom theme after upgrading to 5.3

  • Resolved Gerald

    (@gerital)


    After upgrading to WordPress 5.3 this Javascript error shows up in the console:

    Uncaught TypeError: $ is not a function
        at bindPlayer (xrcbplayer.js?ver=20180910:114)
        at HTMLDocument.<anonymous> (xrcbplayer.js?ver=20180910:95)
        at i (jquery.js?ver=1.12.4-wp:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
        at Function.ready (jquery.js?ver=1.12.4-wp:2)
        at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)

    I know that it is a problem of my custom theme – but it wasn’t there with WordPress 5.2. So I would like to know if there have been made any chances to jQuery I should have in mind in 5.3?

    I already fixed it by changing all $ appearances to jQuery, or put everything inside jQuery(document).ready(function($) { });.

    But I still would like to know why this happened. It seems to me so that the order of loading libraries has changed somehow…

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Riad Benguella

    (@youknowriad)

    hi There!

    This happened because the mediaelement.js script was leaking jQuery as $ in previous WordPress versions. This was fixed recently.

    See https://core.trac.wordpress.org/ticket/48568 for more information. The recommendation in WordPress is to always use jQuery instead of $.

    Thanks.

    Gerald

    (@gerital)

    Thanks for the explanation.

    bellarmino

    (@bellarmino)

    Scusate amici.
    Dopo un aggiornamento mi è stato restituito il seguente errore.
    Chiedo scusa ma sono un principiante. Grazie.
    ______________________
    Warning: Declaration of PLL_Walker_Dropdown::walk($elements, $args = Array) should be compatible with Walker::walk($elements, $max_depth, …$args) in /web/htdocs/www.acpr.cloud/home/wp-content/plugins/polylang/include/walker-dropdown.php on line 0

    Benjamin Chris

    (@lurenjiasworld)

    I have developed a plugin to solve this problem (not permanently).

    The link of this plugin is https://github.com/LuRenJiasWorld/jQuery-WP53-Fix .

    Just install it and see what you can get, if everything works as expected, all errors related will disappear in the console, and your plugin will work fine.

    If you have any problems when using this plugin, feel free to submit the issue.

    Best regards.

    • This reply was modified 1 year ago by Benjamin Chris. Reason: Fix typo

    I activated your plugin but it was no help.

    The error is still there for me.
    https://mika-sushi.ca/my-account/

    If you can help me take a look would be great.

    @tomsychau That’s because the plugin has load after the scripts that depends on jQuery. You should check the load sequence and make sure the var $ = jQuery; code load before all other scripts.

    How do I check? Where do I check?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘jQuery error in custom theme after upgrading to 5.3’ is closed to new replies.