Can I detect when requirejs generates script errors due to user navigation before loading all the specified modules?

I disabled the onError function to return to our server whenever the browser detects client-side errors. It helps us to catch JavaScript errors that can affect our application and is very useful.

However, onError is triggered as crazy on demand if the user moves before requirejs executes, loading all of its modules. An easy way to play back is to load one of our pages and then quickly move around before everything is loaded.

I am wondering if there is a way to check for these errors due to the user moving around?

Here is an example:

requirejs error example Any ideas would be greatly appreciated.

+4
source share
1 answer

So, the way that I will do this looks like this:

Since we donโ€™t want to register errors caused by the fact that the user moves away from the page, we should be able to determine whether we can detect when the user leaves the page ... It turns out we can using the beforeunload event of the window object. What would I do on window.beforeunload, just remove the event handler / handler for the requirejs onError event.

0
source

Source: https://habr.com/ru/post/1542721/


All Articles