Why does Raven.js / Sentry say jQuery is undefined

I get a lot of errors in Sentry saying that "ReferenceError: jQuery is undefined", but still this happens quite rarely compared to the total number of page loads.

<script src="/js/compiled/jquery.min-2fe08f7.js" defer></script>
<script src="/js/my-script-e6f35a4.js" defer></script>

Where my- script.js is something like:

(function($) {
    $('h1').text('Hello world');
})(jQuery);

but I have no clue from the Sentry report why jQuery was not loaded.

The only clues presented in breadcrumbs are pretty worthless:

12:15:25 sentry ReferenceError: jQuery is not defined
12:15:25 sentry ReferenceError: jQuery is not defined
12:15:26 exception ReferenceError: jQuery is not defined

Pending scripts should be loaded in the order in which they appear in the document, so I don’t think the problem is with asynchronous loading.

Perhaps jQuery file timeout on some slow devices? or was the file unavailable on the server at some point?

JS , , jQuery. - , , , , Sentry, HTTP , JS , , ?

.

+9
1

, , DOM , .

, jQuery , $(document).ready(), , , - my-script.js

document.addEventListener("DOMContentLoaded", function(event) {
   (function($) {
     $('h1').text('Hello world');
   })(jQuery);
});
0

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


All Articles