-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sharing: Need to ensure jQuery loads earlier #4661
Comments
Suggestion: check for the wp_add_inline_script function (WP 4.5 and later) and switch to using that instead, so that you can have the output sure to happen after jQuery. For earlier versions of WP, probably simply put that script output into its own action hooked to wp_footer, with a lower priority. |
Related: #1223 |
Thanks @Otto42! 4.5 will be our minimum version supported once 4.6 ships, so that'll be the way to go. |
#6977 Nothing has been fixed here! I am sorry but that is the case.
Note:I have no experience developing with wordpress. Just an end user, curious to know, If Jetpack wants us to host sites with unchecked dependencies or wants us disregarding time to first paint by forcing jQuery and such Huge JS Libraries to Block Rendering basic content only because Jetpack needs libraries downloaded and parsed. |
@Nitin-Prabhakar I'm going to be picking up the discussion on the other issue then, as while the symptoms may be similar, the causes are different. Also, notifications can sometimes be wonky and easy to miss on closed issues. |
Sure! Thanks Much for the attention it needs 👍 |
To reproduce:
_s
without any other plugins active. _s, out of the box, does not enqueue jQuery.Expected:
No JS errors in the console
Actual:
jQuery not defined error.
What's happening is we're enqueuing sharing.js in the footer (with jQuery as a dependency) here: https://github.com/Automattic/jetpack/blob/4.1.0/modules/sharedaddy/sharing-service.php#L536
Within that same function, we're then calling the
display_footer
for each enabled function:https://github.com/Automattic/jetpack/blob/4.1.0/modules/sharedaddy/sharing-service.php#L548
display_footer
is callingjs_dialog
for that service. Example: https://github.com/Automattic/jetpack/blob/4.1.0/modules/sharedaddy/sharing-sources.php#L727js_dialog
is printing JS straight to the OB, including the jQuery call: https://github.com/Automattic/jetpack/blob/4.1.0/modules/sharedaddy/sharing-sources.php#L331This is all being outputted before the initial function closes, so WordPress enqueues sharing.js (and thus, right before it when it hasn't already been enqueued, jQuery) after we've printed the JS calling jQuery.
Original report: https://wordpress.org/support/topic/jquery-not-defined-10
The text was updated successfully, but these errors were encountered: