Our company recently decided to stop support for iOS 12.3 and below. However a small fraction of users are still on older devices that do not support newer JavaScript operators or syntax.
In order to prevent our script from affecting these users we are looking for ways to stop our script from loading if iOS v12.3 or below is detected.
Our JS code is loaded onto client websites via script tags like so:
<script src="exampledomain.com/example.js"></script>
Our first idea was to detect the useragent like this post but there are some problems with this approach.
It is strongly advised against for several reasons outlined here
Detecting the user agent within our script means that it still loads and throws errors when iOS <12.3 encounters syntax it cannot handle.
Detecting the user agent using conditional javascript on our client websites before loading our script is a possibility but difficult to maintain and not ideal for our customers.
Another option is to point the src of our script element to a script that can detect the UA and serve different versions of our script. However our script is time sensitive and the additional time it takes to make 2 requests instead of 1 is something we would like to avoid.
Lastly it is also possible to detect iOS versions without using the useragent by specifically targetting features that are not supported. For example using the nullish coalescing operator (??) in a try catch statement could indicate that the device is below iOS 12.3. But this method also relies on running JavaScript directly on the client website or doing multiple requests.
I would like to know if there are alternative methods we have not considered. Thanks.