How to fix long running scripts?
<p>I'm working on building a leaflet map with a bit of data. Overall, I will have any where between 0 and 18000 marker points on the map at any point in time. </p>

<p>Necessary code to understand what I am attempting to achieve:</p>

<pre><code>var ds = L.markerClusterGroup({
                                disableClusteringAtZoom: 9,
                                maxClusterRadius: 120,
                                chunkedLoading: true,
                                iconCreateFunction: iconCreate
                            });

window.onload = function(){
    map = L.map('map', {
        layers: [baseLayer, ds],
        worldCopyJump: true,
        minZoom: 3,
        inertiaMaxSpeed: 300
    }).setView([lat, lng], zoom);

    callAjax("/ajax/markers1.php", markers); // 4220 rows

    // callAjax("/ajax/markers2.php", markers); // ~14000 rows
}

function callAjax(url, cb, options){
    var xhttp = new XMLHttpRequest(),
        opts  = options || {};


    xhttp.onreadystatechange = function(){
        ajaxCheck(xhttp, cb, opts);
    }

    xhttp.open("POST", url, true);
    xhttp.send();
}

function markers(xhttp){                    
    var dJson = JSON.parse(xhttp.responseText);

    for(var d = 0;d &lt; dJson.length;d++){
        addMarker(dJson[d]);
    }
}

function addMarker(d){                
    L.marker([d.lat, d.lng], {
                id: d.id
            })
     .addTo(ds);
}
</code></pre>

<p>The above code grabs a JSON request from the specified URL and loops through the return to add the markers to the cluster group that is already tied to the map. In Chrome 49.0.2623.112 m it takes the first AJAX response to return after 8 seconds and another 3 to 5 seconds to load all the markers.</p>

<p>In IE 11 I get long running script. There are 4220 records in the first marker run. I have limited the loop to run only 100 times and it still gets long running scripts. Making it only output 1 marker works, but I need all 4220 (and later 14000).</p>

<p>I have found different places where "long running scripts" have been posted, but each ends up saying "Make your code better". For the task I'm attempting to accomplish my code feels to be perfect. </p>

<p>What am I missing on controlling IE so that this code can successfully run and eventually add all 18000+ markers on this map?</p>