Skip to content
Advertisement

$(document).ready not firing on iOS

I have the following code on my page:

<script src="//path.to/jquery.min.js"></script>

<script>
 /* Statements #1 - Defining some variables... */
</script>

<script>
$(document).ready(function () {
 /* Statements #2 - Doing some stuf... */
});
</script>

The above code runs well on Desktop and Android devices, but when running on iOS devices the Statement #2 doesn’t work. I’ve checked the console, and there are no errors.

Just for testing, i’ve executed Statements #2 on console by copy/paste and it runs as expected – This don’t work only automatically, with page loading complete.

PS.: I got the error on iOS devices – Testing with Safari on iPhone and debugging on a Windows 10 with Chrome remote using iOS Webkit Proy

Answer

I’ve found the problem: Somewhere in my code, i had a function with a predetermined value, and only Safari thrown an error. So, i’m using this:

function myFunction(parameter) {
    /* Coll stuf here... */
}

Instead this:

function myFunction(parameter = undefined) {
    /* Broken code... */
}
Advertisement