Faced such a problem - there is a need to execute a certain script on JS , but since in the old versions of IOS for Iphone 6 (Safari version 8 and below) some methods from this script are not supported, and the alternative to come up with a very long and labor-intensive. It was decided not to run the execution of this script. Something like this:

 window.onload = function() { console.log("OK"); function animationCounter() { if ((body.width() < 350) && (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i))) { console.log('Это яблофон'); return; } console.log("Мы пользуемся адекватным браузером, работаем дальше"); } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

but it turned out that everything is not so simple, and the browser's parser will not care if the function is initialized or not, it just freezes if it cannot “read” a specific function at the time of loading the page.
The question is how to get around this? How do you tell browser Safari v8 and below that if you can’t do something, then just skip, and don’t interrupt all other scripts on the page?

  • "the browser's parser will not care if the function is initialized, or not, it just hangs" - ?? - Igor
  • He comes to those lines of code that he does not understand, and blocks all further code until he becomes syntactically clear what they want from him. - BlackStar1991
  • one
    Until we become syntactically clear what you want, we too will hang. - Stepan Kasyanenko
  • How to write a function that will be worked out in all browsers except mobile Safari v8 and below, taking into account that certain methods are not supported in this browser and all that will be after this function will be invalid. the work will be stopped. (For example, I can offer the .addColorStop method - this is from working with the canvas) So I hope you understand it? - BlackStar1991
  • Try before calling the function to check if it is typeof canvas.addColorStop === 'function' . - Tsyklop

0