I've got BugSnag in place to monitor JavaScript errors on my front end. I'm noticing a small percentage of users, under 1%, are receiving errors such as:
jQuery is not defined
Bootstrap's JavaScript requires jQuery
number_format is not defined
...And so on. The scripts are being loaded in my template using standard script tags:
<script src="/vendor/jquery.js"></script>
<script src="/vendor/bootstrap.min.js"></script>
<script src="js/misc.js"></script>
<!-- Page-specific scripts here, typically relying on the above scripts -->
In all these cases I have more than one script being loaded which depends on the scripts that are loaded before it. For example, number_format
is defined in misc.js
, and then used in the page-specific scripts where an error then occurs. Or jQuery is loaded first, and then used by Bootstrap which is loaded second.
It appears that certain scripts are just failing to load for some users, but the next script is successfully loading to find its dependencies missing.
My question is this: Is this type of failure to load scripts unavoidable, caused by something like a network hiccup for specific users? Is it appropriate to simply ignore these knowing that it's not an actual error with my code? Or is there something I can do to prevent this error when a script loads but it's dependency doesn't?
Thanks!