jQuery not working over mobile internet: solved

posted by Paul - 09:37 20/01/12

Whilst developing a mobile site recently, we came across a peculiar bug in which jQuery would not work on devices using 3G mobile internet (when viewing the site over wi-fi, everything worked fine).

We managed to pinpoint that the issue only occurred for people on the O2 network. It seems there is also the same issue for people in Holland using T-mobile.

A little more probing revealed that the problem is that the O2 network compresses and combines all javascript files together in order to reduce the number of server requests when the page loads to speed up the load time.

Whilst this sounds useful in theory, this actually causes any jQuery file after version 1.5.1 to stop working!!

The Solution

The solution to this was to use the CDN (Content Delivery Network) version of jQuery rather than hosting it locally with the rest of the site, since it cannot be compressed with the other files due to being on a separate server.

Normally, I wouldn’t approve of hosting anything so important externally as you don’t have full control over it. On the other hand, it’s hosted by Google, so it’s fair to say it’s not going to go offline anytime soon!

I’ve since read in Web Designer magazine that the CDN version of jQuery downloads faster than hosting locally, so it’s recommended to use that anyway.

There you have it, a fairly simple fix to an obscure bug. I hope you found it useful!

Further Reading

There are no comments yet - why not be the first to leave one?

Leave a comment

CAPTCHA code image
Speak the codeChange the code