DOM performance in Javascript and

ronaldbrass

New Member
I have an question about performance of loading alot off DOM objects. First i have an array of the length of 9540, of something like this:\[code\]{"Id":144412,"GisX":55.50963,"GisY":9.77794}`)\[/code\]The problem is not the loop, but the problem is then i load all the click event to the DOM, which takes 1200ms in Chrome(IE it takes 8700ms), the problem is in Leafletjs using markerCluster. But any idea to increase the performance.\[code\]for (var i = 0, obj; (obj = MarkerArrayDefs); i++) { setMarker(obj.Id, obj.GisX, obj.GisY, i);} //The for loop takes: 151.000msvar markerList = [];function setMarker(propId, lat, lng) { //var marker = new L.Marker([lat, lng]); var marker = new L.Marker([lat, lng], { icon: customIcon }).on('click', function () { var markeren = this; var popup = L.popup({ offset: (new L.Point(-10, -47)) }).setLatLng(markeren.getLatLng()).setContent('<div><span style="color: #4a6b0e; font-weight: bold;">Henter</span><br><img alt="Progress" src="' + ol.url("~/Content/Css/images/mapWaiting.gif") + '" id="imgProg"/></div>').openOn(folia.map); $.get(ol.url('~/ControllerHelper/MapContent/'), { id: propId, callType: searchfilters.ItemType }, function (data) { popup.setContent(data); }); }); markerList.push(marker); return false;}markers.addLayers(markerList); //This takes: 0.000ms.map.addLayer(markers); // This is the problem: 1200.000ms\[/code\]
 
Back
Top