Does JavaScript run when application is in the background?
Asked Answered
B

0

6

Let's imagine I have a website with a simple javascript:

t = setInterval( callback, 30*1000 );
var callback = function() {
    document.write('foobar');
};

If a user visits my site from a mobile device, I'm wondering whether the callback will continue to execute after the page/app is in the background. I know that all mobile devices are not the same, so for clarity let's identify some specific scenarios:

  1. iOS device using Mobile Safari
  2. iOS device using native app with a UIWebView
  3. Android device in default internet app
  4. Android device using native app with WebView

In which (if any) of these cases would the user return after an hour to the screen full of foobars?

update

  1. iOS 8+ (just released at the time of writing this) according to this guy:

now JavaScript continues executing even being the inactive tab (timers are slowed down to 1s frequency) and even being Safari in the background.

Bellyband answered 29/9, 2014 at 1:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.