• Resolved everlearn

    (@everlearn)


    Hi SG Optimizer support,

    SG optimizer creates an error shown as ‘ReferenceError: Can’t find variable: Cookies’ in the Console of Safari (but not in Chrome).

    This error stops Javascripts from working and stops buttons and functions on the Checkout page from working. The error is only there in Safari.

    We discovered the error on our live site and have now tested this on a staging site with only the essential Woocommerce plugins active. The error is there when the SG Optimizer plugin is active and disappears as soon as the plugin is turned off. The error is not present in Chrome.

    If you reload the page, the error shows up 4 out of 5 times, so not all the time.

    The problem is that this error stops our customers from login before a purchase or entering a coupon code among other things, because the Javascripts don’t work.

    Please advise.

    Kind regards,
    Rob

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter everlearn

    (@everlearn)

    I have found the cause of this issue.

    The ‘Load Render-blocking JavaScript Files Asynchronously’ setting in the Frontend Optimization preferences of SG Optimizer was turned on. When we turned this off the error disappears. This is a shame as we gained a lot of speed advantages by loading Javascripts asynchronously so they don’t block the loading of pages on our site.

    Is this a known issue and will this be looked into?

    For the record, this error happened even though all plugins were inactive except for the Woocommerce and SG optimizer plugins.

    Plugin Author Stanimir Stoyanov

    (@sstoqnov)

    SiteGround Representative

    Hey @everlearn

    Would it be possible to provide url to your site please?

    I think that you should exclude one(or more scripts) from async functionality, to address the issues.

    You can use the code below:

    add_filter( 'sgo_js_async_exclude', 'js_async_exclude' );
    function js_async_exclude( $exclude_list ) {
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    Regards,
    Stanimir

    Thread Starter everlearn

    (@everlearn)

    Hi Stanimir,

    Thank you for your reply.

    We have now turned off the ‘Load Render-blocking JavaScript Files Asynchronously’ setting in the SG Optimizer plugin so you won’t be able to see the error anymore.

    But if you want to check out the page, you can use the link for the product page below and click the big green purchase button on the right. If you then click the green button on the cart page, you get to the checkout page that gave us the error and where no JavaScripts would work.

    https://www.everlearn.nl/training/premiere-pro-geavanceerde-montage/

    Thanks for responding!

    Regards,
    Rob

    Plugin Author Stanimir Stoyanov

    (@sstoqnov)

    SiteGround Representative

    I just checked your site, and I’ve tried to exclude each of the scripts from async load, but the issue still exists.

    I recommend you to keep this functionality disabled.

    Regards,
    Stanimir

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug in SG optimizer creates ‘ReferenceError: Can’t find variable: Cookies’’ is closed to new replies.