Count to target with javascript extended
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN "http://www.w3.org/TR/html4/strict.dtd"&gt; 
&lt;html&gt; 
&lt;head&gt; 
  &lt;title&gt;Count to a particular target&lt;/title&gt; 
&lt;/head&gt; 
&lt;body&gt; 
&lt;h1 id="myDiv"&gt;Starting&lt;/h1&gt; 
&lt;script type="text/javascript"&gt;

 var zCurrentValue = 100, zTargetValue = 1000, zTicks=0; // z-prefix synonym with control variables
 getHostValue(); // initial load of server data        
 intervalCheck(); 

function intervalCheck() {
  zTicks++; 

  if (zTicks==100) getHostValue(); // limit reached - get stuff
  if (zCurrentValue == zTargetValue) return; // equal - stop processing over all

  zCurrentValue &lt; zTargetValue ? zCurrentValue++ : zCurrentValue--; // get closer to target ...
  document.getElementById('myDiv').innerHTML = 'Total word count:'+ zCurrentValue.toString(); // visualisation
  setTimeout(intervalCheck,Math.max(20, 1000 - Math.abs(zCurrentValue - zTargetValue))/10); // fiddle the milliseconds
}
function getHostValue() {

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() { (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) ?   zTargetValue = xmlhttp.responseText : zTicks=0 ;  } // zTicks = 0 always true, at least once
xmlhttp.open("GET","target.txt",true);
xmlhttp.send();
}
&lt;/script&gt; 
&lt;/body&gt; 
&lt;/html&gt;