speeding up the recursive function
<p>The function below, will change the <code>&lt;meta ... content="...densityDPI=250dpi" /&gt;</code>
so the density DPI will be reduced 20dpi each time it loops.</p>

<p>is there a way I can speed this up, so it does it in about 4 loops by comparing the ratio of previous values...? I think there should be a something before the <code>x++</code> the can change the 5 to something a little larger so that <code>$(window).width()==480</code> alot faster.</p>

<pre><code>$(document).ready(function (){
        $('meta[name="viewport"]').remove();
        $('&lt;meta name="viewport" id="the_vp_special" content="width=320,target-densityDPI=250dpi"/&gt;').appendTo('head');
        setTimeout(function (){
            var x = 0;
            var changeDPI = function (curr){
                x++;
                var sub = 5;
                if(x&gt;500)  return false;
                var curr = curr?parseInt(curr):320;
                curr = curr-sub;
                var txt = $('&lt;meta/&gt;',{name:"viewport",id:"the_vp_special",content:"width=320,initial-scale=1,target-densityDPI="+(parseInt(curr))+"dpi"}); 
                $('#the_vp_special').replaceWith(txt)
                if($(window).width()==480) {}
                else setTimeout(function (){ changeDPI(curr); },5);
            }
            changeDPI(250);
        }, 2500);
    });
</code></pre>

<p>Please ask away, I will try to explain it better if this is not clear.</p>
