The first question we need to ask ourselves is, what happens
when our web page goes to the background because the user switches
focus to another application (in multitasking operating systems) or
opens or browses to another tab or window? Another problem is what
happens when the phone goes to sleep (because of the user’s inactivity
while the script is executing). The behavior of timers can be a little
tricky in these situations.Yet another problem is that timers execute on the same thread as
the main script. If our script is taking too much processor time (a
normal situation with large scripts on low- and mid-end devices), our
timers will be delayed until some spare execution time is
found.If we use a low frequency for the timer (for example, 10
milliseconds), the timer will generally have problems meeting the
timetable.Remember that the JavaScript execution time depends a lot on the
device hardware and the browser’s engine. Even if they’re running the
same operating system, like Android, execution times can differ: for
example, an HTC G1 will be much slower than a Nexus One with a 1-Ghz
processor.