Home › Forums › Calendar Products › Events Calendar PRO › jQuery Handle Issue
- This topic has 6 replies, 3 voices, and was last updated 9 years, 6 months ago by
Matthew.
-
AuthorPosts
-
October 4, 2016 at 9:35 am #1172370
Matthew
ParticipantHello there!
We ran into an issue where The Events Calendar wasn’t working correctly. All of our theme JS was working correctly (built from a custom theme boilerplate we created called prelude-wp), but the archive view for TEC was failing (but with no errors in the console – see front end issue in screenshot).
I spent a lot of time deferring scripts, changing jQuery versions, disabling plugins to no avail. It still kept failing. If and when I did get TEC to work correctly, the rest of our theme JS would fail. I narrowed it down to one function in functions.php where we deregister the WordPress jQuery version and register our own:
/** * Load jQuery */ if ( !is_admin() ) { add_action('wp_enqueue_scripts',function() { wp_deregister_script('jquery'); wp_register_script('prelude_jquery', ('https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'), false); wp_enqueue_script('prelude_jquery'); }); }I found that changing our new jQuery enqueue handle back to just “jquery” fixes the issue all around, TEC works, our custom JS works. All is peachy. My question/concern is why this is the case? Is the TEC plugin reliant on a script dependency called “jquery?” The reason we changed the new jQuery handle was to avoid conflicts with other plugins (we had a plugin that was disabling jQuery automatically at one point).
Thanks for any insight!
October 4, 2016 at 5:28 pm #1172523George
ParticipantHey Matthew,
Thanks for reaching out.
In explaining your findings, you pose this question:
Is the TEC plugin reliant on a script dependency called “jquery?”
☝️ YES — jQuery is a JavaScript library that many, many plugins and themes require to be loaded. This script is included by default in WordPress, and it is very bad practice to ever “deregister” this built-in copy of jQuery.
There may be one specific JavaScript issue happening, and so I would recommend trying to find out that specific issue instead of throwing out jQuery altogether.
I am happy to help find out what that error is!
1. To help us do that, can you first please post your site’s system information? Here is how to do so → https://theeventscalendar.com/knowledgebase/sharing-sys-info/
2. Next, please deactivate ALL PLUGINS on your site except for just The Events Calendar, Event Tickets, and any premium add-ons you may have for these, like Events Calendar Pro or Event Tickets Plus. Leave your theme active.
3. Then, remove ANY scripts from your theme that you have added that alter the version of jQuery being loaded.
4. Finally, once your site is in this state, leave it in this state and share a link to a page on your site where The Events Calendar is not working.
☝️ Once your site is in the state of #4 here, I will look at the issue firsthand and see if I can spot the exact problem.
I know that it’s inconvenient to leave your site in this state! But I can assure you I will work as quickly as possible to minimize the amount of time you have to leave your site in this state….
Thanks,
GeorgeOctober 5, 2016 at 8:49 am #1172711Matthew
ParticipantHi George!
I think maybe my question got lost in translation here. I understand that jQuery is a dependency of The Events Calendar, but my question was more aimed at the “handle” that jQuery is registered as in WordPress. By default WordPress has jQuery registered as a script called ‘jquery’, and in this specific custom theme we have jquery registered as ‘prelude_jquery’. The issue is 100% resolved by renaming our jQuery handle in WordPress back to just the default handle of “jquery”. So my question was does TEC look for a script dependency with a handle of “jquery”?
All in all we decided internally to update our theme to not have the custom handle name for jQuery so it won’t be an issue in the future, but was just looking for insight into what TEC is looking for when it comes to handles of dependent scripts.
Thanks!
October 5, 2016 at 8:13 pm #1173045George
ParticipantHey Matthew,
Thanks for elaborating here.
You write:
By default WordPress has jQuery registered as a script called ‘jquery’, and in this specific custom theme we have jquery registered as ‘prelude_jquery’.
☝️ What’s worth noting here is that your code also removes the existing ‘jquery’ handle.
It is very bad practice to register any version of jQuery in WordPress other than its default included version. The handle for this included version is indeed ‘jquery’.
Part of the reason this is such bad practice is that, yes, many plugins and themes—including The Events Calendar and its add-ons—require jQuery. And to specifically address your question, yes, this means that they look for the core script whose handle is ‘jquery’ specifically.
I hope this more accurately addresses your questions! Let me know, and let me know as well if there is anything else I can try to help with. 😀
Cheers,
GeorgeOctober 6, 2016 at 8:37 am #1173223Matthew
ParticipantMakes perfect sense, and we’ve since changed our theme back to the default handle and will deal with the “bad” plugin that was causing the issue (why we changed it) in the first place. Thanks!
October 6, 2016 at 5:26 pm #1173512George
ParticipantSounds good, Matthew. Open a new thread here in the forums any time if other issues or questions arise! 😀
— George
-
AuthorPosts
- The topic ‘jQuery Handle Issue’ is closed to new replies.
