Javascript Timers and Opera Mini 2

Friday, May 5th, 2006

Opera Mini 2 is out. This is a source of some excitement to me as we have long been interested in developing applications for mobile devices and at long last it looks like we might be able to do this through a browser interface. We’re especially interested to see how well it supports websites written with AJAX technologies.

Opera have made a smart move creating the excellent Opera Mini Simulator. The simulator is not only a cool promotional tool but serves as a useful resource for developers like myself to not only test our websites for compatibility, but more interestingly to test out our mobile AJAX experiments. It was while testing one of these ‘experiments’ I noticed that the Javascript timer function setTimeout didn’t seem to work with the current version of Opera Mini. The timer function is used in AJAX based solutions to achieve visual effects that happen over time (see and moo.fx) but also for ‘suggest’ functionality (see google suggest for an example). So needless to say we were very surprised and not a little disappointed to find that the setTimeout function didn’t seem to work with Opera Mini.

To double check this I created a simple timer based example that can be run from a desktop browser and Opera Mini’s Simulator for comparison.

The Javascript looks like this:

var count = 0;

function refreshPage()
  count = count + 1;
  var counter = document.getElementById("counter");
  counter.innerHTML = 'count='+count;

function update()

You can see it in action and view the html here.

You should find that it works in your desktop browser but not in the Opera Mini Simulator. Just to check that it wasn’t just me I checked out Google Suggest from within the simulator and although the page rendered beautifully – the suggest part of it didn’t work!

Google Suggest using Opera Mini 2.0

It seems strange to me that Opera have omitted the Javascript timer as the Opera Browser seems an ideal platform to write applications for mobile phones. Looking at their desktop browser strategy of allowing developers to create widgets it seems that they are encouraging developers to create small opera based applications that run outside of the browser and that even work when not connected to the internet!

It’s easy to see the potential for writing ‘write once run anywhere’ applications for mobile phones if they extended the widget strategy to their mobile browser, however it’s going to be very limiting without some sort of javascript timer function! It can’t be true – I must be doing something wrong! I’m off to the Opera forums to find out!

Update – Dec 6th, 2006

Opera Mini 3 has recently been released. Unfortunately it still doesn’t support setTimeout! However Opera for the Nintendo DS does support it! Progress?

Update – Nov 7th, 2007

Opera Mini 4 is out! Still no setTimeout support. Ther’s a telling paragraph in Chris Mills’ article JavaScript support in Opera Mini 4 :

Sites that use Ajax to trigger very regular page changes however, such as Google Suggest and the automatic new mail functionality of GMail mentioned above won’t work. Other examples of things that don’t work are IRC-like chat-clients using server-side events, and clocks.

Mark B

Tags: , , ,

Friday, May 5th, 2006 AJAX

2 Comments to Javascript Timers and Opera Mini 2

  • R. Ross says:

    I wonder if the reason could be intentional, related to battery drain on mobile devices…if someone loads the page, then switches to another application on the mobile device, I suspect the browser and javascript keep running in the background. Not a problem if it is a static display, it only takes up memory. But if you had some timers running then it would be continually ‘waking up’ to check the timers. I don’t know if this would create a significant drain on the battery or not.

    I agree that it is frustrating…I wanted a simple clock that would display seconds on my phone and thought a simple webpage was the answer. Interestingly it does work in the version of internet explorer included on my windows mobile device even thought it’s support for other javascript features is somewhat lacking.

    Thanks for the post letting me know that opera mini doesn’t support settimeout thought. You saved me some time.

  • MarkB says:

    R. Ross, it seems that the root of the problem is the pre-execution of Javascript on the server. Due to the limited capabilities of many handsets Opera felt that it was better to do this processing in advance and send the pre-rendered page to the phone.

    Looking at Chris Mills article again I notice that he explicitly states:

    “After the page has been transferred to the client, things are a lot more limited – basically all events are processed on the server. The client does absolutely no JavaScript processing at all, and instead the page is kept in the server (basically the client works as an input device for the opera running in the server). No background scripts running after the page is loaded will be executed, and executing code using setTimeout is not possible. “