cancel
Showing results for 
Search instead for 
Did you mean: 

JS files don't load intermittently

SOLVED

JS files don't load intermittently

I looked through the existing threads on javascript files not loading but the issue seemed different. 

 

Quite often when I load a product page on a new tab, half the content of that page doesn't show. Most often the entire description and below is missing. When I checked the browser console I can see that a lot of the JS files are missing. But when I refresh the page it works fine and everything shows. 

 

See the behaviour here:

https://www.awesomescreenshot.com/video/16927323?key=ebc0b262cebd7b2d623613c0cb797f16

How can I debug to see why those files aren't being loaded?

 

Here's a page on our test site:
http://mag04.stockpile.lk/icc-precast-concrete-top-pile-9000x300x300.html

 

Thanks,

Charith

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JS files don't load intermittently

Hi thanks for your reply. 

 

We found a different issue that resolved it. 

https://prnt.sc/DQNb6iD27eTI

 

This was due to a module that wasn't being used. I followed some of the suggestions mentioned here: 

 

https://magento.stackexchange.com/questions/328363/uncaught-typeerror-cannot-read-property-remove-of...

 

The code that was causing the error was this:

<script>
    require([
        'Magento_Customer/js/customer-data'
    ], function (customerData) {
        var sections = ['cart'];
        customerData.invalidate(sections);
    });
</script>

By disabling that module I was able to resolve the issue completely. 

 

Thanks!

View solution in original post

2 REPLIES 2

Re: JS files don't load intermittently

It looks like the issue is related to the timing of loading the JavaScript files. The issue occurs when the page is loaded for the first time, but it disappears when the page is reloaded. This suggests that the problem is not with the JavaScript files themselves, but with the way they are being loaded.

 

One possibility is that some of the JavaScript files are being loaded asynchronously, which means that they are not being loaded in the order that they are specified in the HTML. This can cause problems if one script depends on another that has not yet loaded.

 

To debug this issue, you can use the browser's network tab to see which files are being loaded and in what order. You can also check the console for any error messages related to the missing files.

 

To fix the issue, you can try to load the JavaScript files synchronously so that they are loaded in the order that they are specified in the HTML. Alternatively, you can try to delay the execution of the scripts until all the necessary files have loaded.

 

Another possibility is that the server is not properly configured to serve the JavaScript files. In this case, you should check the server logs for any error messages related to the missing files, and make sure that the server is configured to serve the files with the correct MIME type

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: JS files don't load intermittently

Hi thanks for your reply. 

 

We found a different issue that resolved it. 

https://prnt.sc/DQNb6iD27eTI

 

This was due to a module that wasn't being used. I followed some of the suggestions mentioned here: 

 

https://magento.stackexchange.com/questions/328363/uncaught-typeerror-cannot-read-property-remove-of...

 

The code that was causing the error was this:

<script>
    require([
        'Magento_Customer/js/customer-data'
    ], function (customerData) {
        var sections = ['cart'];
        customerData.invalidate(sections);
    });
</script>

By disabling that module I was able to resolve the issue completely. 

 

Thanks!