One thing that I came to grips with today is the fact that if an error occurs in one of the functions that was bound to the document’s ready pseudo-event (I say this because the event doesn’t necessarily exist in every browser) by using jQuery, none of the subsequent callback functions will execute unless another function is bound to the event after the DOM has loaded. It took me about fifteen minutes to track down the source of this issue. Here is an example of what I mean:


$(function() {
  alert("1st call");
});
$(function() {
  throw new Error("2nd call");
});
$(function() {
  alert("last call");
});

In the above example, only the first alert will be shown. Therefore, make sure that all of your errors are caught in a try-catch clause or prevent them altogether. šŸ˜‰

Categories: BlogJavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *