I've noticed sometimes that one javascript error will break other unrelated javascript functionality and sometimes it doesn't. I couldn't see a pattern in it and this makes debugging difficult (especially when you take on an old project and you don't have time to fix all errors).
For example this code:
$(".div-one").slick({ // settings for slick plugin });
Was breaking this code:
$('.product-options').click(function() {
$('.message').slideToggle('show');
});
when there was no .div-one
element on the page. It retuned an element undefined error. so I wrapped it in an if statement checking for the length of .div-one and now the code works fine.
But obviously there are lots of cases when javascripts error do not break anything.
So when will js error cause problems? The 2 pieces of code were in the same file. Maybe it affects only same file?
Thanks!