Magento – Magento 2 – Checkout loader keeps loading

checkoutmagento-2.1magento-2.1.2magento2onepage-checkout

Issue: Loader won't stop loading after page loading is finished.

In this question Irene891 gave this as an answer:

"looks like problem caused by missed "checkoutLoader" configuration. Try to to add for div with id = "checkout-loader" data-mage-init='{"checkoutLoader": {}}'"

This is what I currently have:

<div id="checkout-loader" data-role="checkout-loader"
    class="loading-mask" data-mage-init='{"checkoutLoader": {}}'>

I've checked the file onepage.phtml in module-checkout on line 10 data-mage-init='{"checkoutLoader": {}}' is present.

When I check the page http://[url]/checkout/ with the developer tools, I can see when the page is loading data-mage-init='{"checkoutLoader": {}}' is present, but when the page is almost finished, it dissapears.

I'm looking for a good solution for this problem. A solution that doesn't include to remove the whole loader on the checkout page.

Best Answer

TL;DR

Check out your browser's extension and see if your Ads Blockers are intervening with your website fetching files.

Description:

I managed to solve my issue and I'm now writing this solution hoping to help future viewers.

For me, the issue was occurring in Firefox only, not Google Chrome.

The issue was exactly as you described. data-mage-init='{"checkoutLoader": {}}' disappears after few seconds from the page loading. The loading GIF keeps loading on screen not allowing the user to interact.

Debugging:

After looking into Firebug console, I found the following line:

Error: Script error for: trackingCode http://requirejs.org/docs/errors.html#scripterror 

I saw that lines many times while debugging, but never took the time to think about it. It turned out that I have an Ads Blocker Extension installed on my Firefox that caused an error by blocking some scripts (my understanding based on an assumption of what ads blocker do).

My Firefox had two advertisement blocking extensions uBlock and AdBlock, while Chrome had only AdBlock installed.

Solution:

I turned off uBlock from working on my website in Firefox, the checkout page worked fine. Then I went and disabled uBlock all along keeping AdBlock. My checkout page loads fine.