I was working on a site that required a small jQuery function to load only if the site was opened on an iOS device, ie. the iPad, iPhone or iPod. All you need to do is include a little call to the window useragent to test if the browser being used is an iOS browser.

Here is the code snippet:

userAgent = window.navigator.userAgent;
if(/iP(hone|od|ad)/.test(userAgent)) {
  // add your script here
}

If you wanted to add a script to regular browsers but not to iOS browsers you can just modify the above snippet like so:

userAgent = window.navigator.userAgent;
if(/iP(hone|od|ad)/.test(userAgent)==false) {
  // add your script here
}

It’s nothing that fancy but it works.