generoi / sage-woocommerce

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js are being executed twice only on woocommerce pages

SergiArias opened this issue · comments

I am trying to find the bug in my site, where alpinejs framework didn't work properly, and I found that only on woocommerce pages js is being executed twice.
I still cannot know if the cause is the generoi package, but I think it's the most probable candidate.
You can take a look at this page to view the bug. I will try to replicate in a clean site, but meanwhile, if you open the console, the console logs are loaded twice, and thus alpine becomes unusable for some of its features. If you go to a regular page the console logs are being loaded once.
If the issue is not the package I apologize in advance. In case you know where I can start looking it will be much appreciated.
I found a chrome bug filed with this problem, but it seems there are multiple potential causes (htaccess, favicon, images without src...). I tried with firefox and it gave the same problem. But only after the second reload, so I guess it can be related to browser caching.

Not related to any of my guesses. It was this chunk of code:

add_action('wp_enqueue_scripts', function () {
    bundle('app')->enqueue();

    if (is_account_page() || is_cart() || is_checkout()) {
        bundle('woocommerce')->enqueue();
    }
}, 100);

Reason being that I only want to enqueue css and not js, but I guess the bundle doesn't check if exists.