Google Analytics by MonsterInsights
[Plugin: Google Analytics for WordPress] Load jQuery and comment tracking only if have comments (1 post)

  1. Todd Lahman
    Posted 4 years ago #

    Could you make jQuery loading conditional? Right now jQuery loads as a dependency when the plugin loads the Google Analytics tracking code for comments as shown below:

    <script type="text/javascript">
        jQuery(document).ready(function() {
            jQuery('#commentform').submit(function() {

    On pages that have no comments there is no need to load jQuery or the comment-reply script. I would propose using a condition that checks to see if comments are greater than zero before loading jQuery and the Google Analytics comment tracking code to decrease page load time on pages that have no comments. This is one enhancement that would help our pages load faster.

    if ( get_comments_number() > 0 )

    Thank you for a great plugin.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Analytics by MonsterInsights
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic