• Resolved Global Programming

    (@globalprogramming)


    Hi, we have a plugin that outputs parsed JavaScript through a “Page” on WordPress (headers are set as JS and the files are rendered as JS).

    Problem is now when clients have JetPack stats enabled, JetPack is adding a <script> block at the end of the JS which is causing it to break.

    How can I stop JetPack from outputting its script block on certain pages?

    https://wordpress.org/plugins/jetpack/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    The Stats tracking code is hooked into the wp_footer action:
    https://github.com/Automattic/jetpack/blob/3.9.2/modules/stats.php#L145

    You could solve the issue by removing the wp_footer call from that particular page, or by removing the stats_footer function from wp_footer on the page.

    I hope this helps.

    Thread Starter Global Programming

    (@globalprogramming)

    The page has different content based on different scenarios so it’s not always JavaScript, sometimes it’s a regular page.

    I would need to, dynamically, from within a plugin, disable this – is this a possibility?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    How about wrapping the wp_footer call in a conditional that would only return true when the page is a regular page?

    The other option would be to dynamically remove stats_footer from wp_footer from your plugin.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude JetPack JS block from certain pages.’ is closed to new replies.