-
Notifications
You must be signed in to change notification settings - Fork 800
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
Woo Analytics: use core WP function to enqueue script #13173
Conversation
Related: #13039 For third-parties to be able to interact with our tracking script, it is easier if it is registered using core WP functions instead of just added to wp_head. Using wp_enqueue_script makes it easier to dequeue the file if needed, or modify its output with the script_loader_tag filter (one could add an async parameter for example, or add extra data attributes like the Cookiebot plugin.
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: September 3, 2019. |
Hi @jeherve, thanks for the ping. I'm trying to test this locally but am having trouble turning off development mode so I can connect to wp.com. I tried these with no luck:
My url is |
@psealock What happens if you just comment out all those filters / constants? By default, if your site is publicly accessible, you should be offered the option to connect to WordPress.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jeherve, this a more legitimate way to load the script. I tested locally and the script is loading correctly. I'm not forseeing any issues around dependencies or load order. Requests for t.gif
are firing as they should.
Hmm. Something, which I can't find, is applying the |
I tested this change using the provided testing instructions, and the file was enqueued as expected. Do you think there's any value in adding the async attribute using the |
Good catch @kbrown9! Yes, definitely. |
I tested this PR with commit d184acf using the provided testing instructions. The file was enqueued in the |
* 7.7 changelog: initial set of changes * Changelog: add #13154 * Changelog: add #13134 * Changelog: add #12699 and many others * Changelog: add #13127 * Changelog: add #13167 * Changelog: add #13225 * Changelog: add #13179 * Changelog: add #13173 * Changelog: add #13232 * Changelog: add #13137 * Changelog: add #13172 * Changelog: add #13182 * Changelog: add #13200 * Changelog: add #13244 * Changelog: add #13267 * Changelog: add #13204 * changelog: add #13205 * Changelog: add #13183 * Changelog: add #13278 * Changelog: add #13162 * Changelog: add #13268 * Changelog: add #13286 * Changelog: add #13273 * Changelog: add #12474 * Changelog: add #13085 * Changelog: add #13266 * Changelog: add #13306 * Changelog: add #13311 * Changelog: add #13302 * Changelog: add #13196 * Changelog: add #12733 * Changelog: add #13261 * Changelog: add #13322 * Changelog: add #13333 * Changelog: add #13335
Related: #13039
Changes proposed in this Pull Request:
wp_head
.Using
wp_enqueue_script
makes it easier to dequeue the file if needed, or modify its output with thescript_loader_tag
filter (one could add an async parameter for example, or add extra data attributes like the Cookiebot plugin.Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
head
:<script type='text/javascript' src='https://stats.wp.com/s-201931.js'></script>
(note that the exact filename changes week after week).Proposed changelog entry for your changes: