In the example below, can anyone tell me how to make "slow response when clicked" respond more quickly without modifying appendContent()? I'm wondering if there's a way to place cheap operations before more expensive ones, and make sure the cheap ones actually get carried out quickly.
<div id="draw">slow response when clicked</div>
<div style="overflow: auto; height: 300px; border:solid 1px grey" id="content"></div>
<script language="javascript">
var clickLink = document.getElementById("draw");
var contentDiv = document.getElementById("content")
function appendContent(){
contentDiv.innerHTML = contentDiv.innerHTML + "hello ";
}
clickLink.onclick = function(){
clickLink.style.color = "red";
for (var i = 0; i < 1500; i++){
appendContent();
}
};
</script>