Support » Plugin: What Would Seth Godin Do » jQuery not defined (plugin break) when using Autoptimize to concatenate js files

  • The WWSD plugin operates successfully when all of my javascript files are loaded as individual HTTP requests, but when I turn on any sort of automatic concatenating plugin (currently using Autoptimize, but I have tried others as well) to load all of my site javascript as a single file I get the following error in console:

    Uncaught ReferenceError: jQuery is not defined

    I have tried the following to no success:

    • Changing ‘jquery’ to ‘$’
    • add_action('wp_footer', 'wwsgd_js', 100);
      as mentioned in an older topic here within this support forum.
    • I have even tried moving ` jQuery(document).ready(function() {
      var count;
      if ( !jQuery.cookie(‘wwsgd_visits’) ) {
      count = 1;
      }
      else {
      count = parseInt(jQuery.cookie(‘wwsgd_visits’), 10) + 1;
      }
      jQuery.cookie(‘wwsgd_visits’, count, { expires: 365, path: “<?php $url=parse_url(get_bloginfo(‘url’)); echo rtrim($url[‘path’], ‘/’).’/’ ?>” });

      if ( count <= <?php echo $wwsgd_settings[‘repetition’] ?> ) {
      jQuery(“.wwsgd”).show();
      }
      });` from the plugin’s php file to the bottom of another JS file which I enqueue much later.

    No matter what I attempt to do I can never get WWSD to order itself AFTER jQuery so as to avoid the ‘Uncaught ReferenceError: jQuery is not defined’ console error.

    I am asking for any helpful ideas. Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.