Web site exhibits JavaScript error on iPad / iPhone under 3G but not under WiFi

后端 未结 2 959
有刺的猬
有刺的猬 2020-12-01 12:05

Connecting to http://www.manage-us.com on an iPad under 3G [used to] result in a JavaScript error which can be seen if the developer console has been enabled. If the same p

2条回答
  •  囚心锁ツ
    2020-12-01 12:45

    I've investigated this further and discovered that the problem is that the UK mobile operator O2 (the original exclusive iPhone operator for Apple), modifies web content before sending it to iPhones and iPads. Probably before sending it to any device running a mobile browser.

    They non-deterministically inline some of the CSS and JavaScript into the main source files of the web pages. This can create errors either because of mistakes in their algorithm or the consequence of stripping white space from source files with syntactic mistakes in the source files which were otherwise benign.

    These modifications also strip copyright messages from copyrighted javascript libraries and css libraries and play havoc with delivery optimisations.

    For example, imagine if a user is visiting a sequence of pages on your site which all link to jQuery libraries. Instead of letting your mobile browser locally cache the library, O2 inline the library on every page, forcing your phone to load the entire library over and over again for every page.

    I've written a blog about the issue here in the hope if drawing a bit more attention to this: http://stuartroebuck.blogspot.com/2010/07/mobile-proxy-cache-content-modification.html

    My workaround is to use document.write() to insert the JavaScript library dependencies at load time and prevent O2 from inlining them. This seems to work quite well. e.g.:

    
    

    Note that, as ever, document.write will not work if the page is served as XHTML.

提交回复
热议问题