M
M
m5xim2018-06-27 16:00:37
JavaScript
m5xim, 2018-06-27 16:00:37

Is it possible to make a standalone connection of a js file so that errors on the page do not affect it?

Good afternoon. The essence of the question is this: there is a js file whose functionality is important and which is connected to the page asynchronously

<script type="text/javascript" async src="x"></script>

I conducted a small test, regardless of the connection location (header / body) in Firefox, it works even if there are js errors on the page (both in the document itself and in other included files), in Chrome it does not work if there are other people's errors.
I wrapped all the code in my include file in my scope . Is there any advice/way to avoid other people's errors affecting my js file? PS About the fact that the page should not have js errors at all, I know very well, but it will not depend on me (i.e. the script will be connected on other people's sites), so I would like to hear advice on this. (function () {...}());

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question