0

I'm using the following JS to scroll the window to position 0 to fool the browser into hiding its UI chrome.

if navigator.userAgent.match(/iPhone/i) or navigator.userAgent.match(/iPod/i)
  if document.URL.indexOf("#") is -1
    window.addEventListener "load", ->
      setTimeout (->
        window.scrollTo 0, 1  if window.pageYOffset < 20
      ), 0

You can view the site at http://ssaen.s3-website-ap-southeast-1.amazonaws.com on your iPhone or iPod touch. The scroll happens quickly but there is a big delay before the chrome goes away.

Compare this to http://mobile.twitter.com (you'll have to login to see the main UI), the chromes goes away almost immediately. Twitter's scripts are obscured so I can't see them.

Any advice?

4

1 回答 1

1

I suspect the JS scripts at the bottom are blocking the page load event. You can try concatenate all the JS files into one and use <script defer>.

Refer to the compatibility table for the defer attribute. Also do look at the async attribute as well.

于 2013-03-30T11:35:38.630 回答