Finally, the problem was in the templates. If there is non-valid javascript or can't be downloaded, the page gets loaded twice (second time without the broken javascript). Just remove the javascript from the template and it works fine.
In my case, there was something wrong in the flexie.js