I am in the course of setting up a site with Roots and am running into problems with the load order of the Javascript / JQuery. One plugin references JQuery before the library is loaded which leads to a ReferenceError (“jQuery is not defined”).
jQuery is in the header to avoid potential conflicts with plugins. Modernizr is also loaded in the header and after stylesheets as recommended by Modernizr.
This is not the case though… Roots’ scripts appear just before </body> and even changing the priority of wp_enqueue_scripts didn’t help push the libraries on top.
Any input / help available? I am in DEV-mode (WP-ENV), does that conflict with or explain anything?
Gravity Forms which uses jquery for conditional fields says, jQuery is undefined because apparently it gets loaded in the footer rather than the header where Gravity Forms requires it.
Trying to determine how to resolve that on a single page where gravity forms loads. But for now, simply trying to temporarily get jquery in the header for all pages to make sure that will infact solve the problem.
Your message here from last year says that in jquery-cdn.php to change “true” to “false” inside wp_register_script. I’ve tried both settings and the position of the jquery remains in the footer. I have gulp watch enabled as well.
For 2016 is there an updated method on resolving this issue? Thanks!
same issue here, to solve the issue, i comment the jquery-cdn support and now jquery is loaded in the header which solves the gravityform issue for now.
Thanks, so much chris4ever. Been struggling with this exact issue. It’s been awhile–is there a better/different way to solve this, or is this still the go-to?
I think it depends on what version of the theme you’re using and whether or not you’ve got the Soil plugin enabled
Typically this isn’t an issue anymore. If a plugin or any enqueued script on your site/theme have jQuery as a dependency and is not defined to be in the footer (the last argument of wp_enqueue_script), then it’s automatically moved to the header.