• Resolved timjrye

    (@timjrye)


    With version 6.4.9, which introduced the [analytics] shortcode, the plugin is enqueuing unnecessary scripts on every page.

    The script appears to be used to make the new widget work on the front end.

    Two reasons this is bad:

    1. The script is being enqueued on every page, no matter whether the widget is being used on that page or not. (I’m not using the widget anywhere, but still the script is being loaded). This is a waste of resources. The script should only be enqueued when the widget is used (just call wp_enqueue_script() when outputting the widget, surely, not on every page!?).

    2. The script is not being enqueued using the proper WordPress method (wp_enqueue_script). If you look in ‘google-analytics-summary-widget.php’ in the plugin folder, you can see that in the function ‘GoogleAnalyticsSummary’ an action ‘addTopJs’ is being attached to the ‘wp_head’ handler. This function simply outputs the Javascript directly, rather than enqueuing a JS file. This is causing two issues on my sites: 1) a ‘jQuery is not defined’ error, since the script is using jQuery and is in the header, but jQuery is not enqueued until the footer, and 2) the script is not being properly handled by other plugins (such as Autoptimize).

    Please fix these issues ASAP! How did these not get noticed during your testing? It is affecting all of my 20 client sites, and I’m sure every other site in the world that has this plugin installed!

    https://wordpress.org/plugins/google-analyticator/

Viewing 1 replies (of 1 total)
  • Plugin Author Garrett Grimm

    (@grimmdude)

    Hi,

    An update has been pushed to temporarily disabled the [analytics] shortcode until this can be resolved.

    -Garrett

Viewing 1 replies (of 1 total)
  • The topic ‘Bad Script Enqueueing in v6.4.9’ is closed to new replies.