skip to Main Content

I am developing a WordPress plugin. I have several JavaScript files (also several CSS and PHP classes). Using the browser’s developers’ tools, I have debugged and optimised the scripts. And all work perfectly in a variety of browsers (like Firefox, Chrome and Safari).

However the scripts will not function on my old iPad (iOS 9.3) which uses the native Safari.

UPDATE: No javascript for Chrome on iOS either.

I have a simple script now:

alert("Hello");

Again it show fine on my desktop browsers.

(I’ve heard Safari restricts sites using http:. My site uses https: though.)

I installed another plugin ("WP Tools", I think) and in WP admin, it reported on the desktops: "Javascript is working …". On the iPad it said "Javascript is NOT working properly…". Other non-WP testers show on the iPad, js is active and working.

Tested on a fresh WordPress with ‘Twenty Twenty-One’ theme – no other plugins.
Can others confirms these results? Is there a work-a-round?

2

Answers


  1. I would have added a comment, but don’t have enough reputation yet 🙂

    It’s likely that the mobile browsers don’t support the same functions, versions, etc. – also Apple don’t always allow app updates if the device is too old. Meaning some apps can have restrictions regarding the iOS version. If that’s the the, you should check if it works on a newer device.

    I have recently heard that some functions in ES6 don’t work at all in mobile browsers, and also popups like alert, confirm, etc. has been disabled in some of the browsers. I haven’t checked this myself, so I can’t really confirm or deny it.

    I would start by checking that your mobile browser supports scripts from other websites in the first place. If it does, I would continue making sure the scripts follow the ES5 syntax if possible.

    If this don’t work, you could remove all of the script code, and adding it back bit by bit to find out where it goes wrong. Another handy "trick" when debugging in WordPress, is to set the version number to fx. time() where you register/enqueue the script. This way you can be sure your browser don’t serve an old version of the script from its own cache.

    Hope it helps a little, and that you figure it out eventually

    Login or Signup to reply.
  2. The quickest and most advisable fix is to force your web app users to update their versions of browsers in order to enjoy all the features of your website. This is because of how browsers interpret your scripts. It is not about the script you write but how your script is compiled or interpreted. Older browser versions targeted the recent JS engine at the time of building the browser and that has remained the tradition till date. It therefore means that the same code you have written over time gets compiled or interpreted a little bit differently with newer versions of JS engine.

    The only other option you may have is to build or find libraries that will make your code backward compatible with older browsers. That will mean that you have a good knowledge of the JS engine at work at the time of the browser version you want to target.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search