Community Forums › Forums › Archived Forums › Design Tips and Tricks › Genesis jQuery not working in child theme, broken after 2.2.7 ugrade.
Tagged: broken, child, child theme, jquery, not defined, not working, referenceerror, theme, uncaught, undefined, upgrade
- This topic has 1 reply, 2 voices, and was last updated 7 years ago by Victor Font.
March 23, 2016 at 9:17 pm #182146B1gJ4k3Member
I'm going to file this under things that don't make any sense...
I recently updated my Genesis theme to 2.2.7 and found all the jQuery broken in my child theme. Getting the error
Uncaught ReferenceError: jQuery is not defined
Looking in the source code, I see that jQuery was no longer being included on the page. WTF??? After beating my head up against the wall for several hours, I decided to work from a blank Genesis child theme downloaded from the Studiopress website. And noticed these two lines need to be included for jQuery to be included:
add_theme_support( 'html5' ); add_theme_support( 'genesis-accessibility', array( 'headings', 'drop-down-menu', 'search-form', 'skip-links', 'rems' ) );
or, at the bare minimum:
add_theme_support( 'html5' ); add_theme_support( 'genesis-accessibility', array( 'drop-down-menu') );
What could possibly be the reason for this? Removing built-in WordPress funtionality and then adding it back in? Is there really much performance gained from removing jQuery, especially if it's undocumented and breaks existing child themes????
(This could have been an issue in previous 2.2 releases. I just updated to 2.2.7 today)
Posting this in case somebody else has the same problem. Hopefully it will save you a few hours of head-banging....March 24, 2016 at 5:03 am #182161Victor FontModerator
If the Genesis 2.2.7 update broke jQuery than there would be hundreds of posts both on this forum and on the Genesis WP Facebook page. Version 2.2.7 has been out for a couple of weeks and yours seems to be a single isolated instance. I've updated dozens of sites to 2.2.7 without any issues. jQuery works on all of them after the update.
For convenience, WordPress registers many popular scripts used by developers, but it does not load them on the front end, jQuery included. It's up to the theme developer to load theme. See https://developer.wordpress.org/reference/functions/wp_enqueue_script/ for more information.
Genesis does not load jQuery either, except as you discovered, when jQuery is a dependency of a Genesis supplied script. In which case, jQuery is loaded by the WordPress wp_enqueue_script function because it was pre-registered by WordPress. The only scripts loaded by Genesis that require jQuery as a dependency are the drop down menu and superfish scripts. If you are not using dropdown menus and/or superfish, then it's up to you to load jQuery in the child theme.
Genesis 2.2.7 did not break jQuery. There's something else going on with your site.
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.