Title: Load areas(array) in chunks
Last modified: August 28, 2018

---

# Load areas(array) in chunks

 *  [andza1](https://wordpress.org/support/users/andza1/)
 * (@andza1)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/load-areasarray-in-chunks/)
 * Hello guys , recently I’ve been struggling with optimizing a js script of this
   plugin. I’m working on a project which is build across this plugin.
 * The question: I got a few maps where they have 3-5 areas which are loaded pretty
   fast but there is one pretty large one where 60 or even 70 areas are loaded. 
   They are loading with lag. I mean on the first page load, the page is more likely
   to freeze on loading all maps.
 * I’ve tried to load areas which are placed in array ( as i understood ) dividing
   them to chunks but i failed , maybe someone already accomplished this ?
 * The code that I tried to implemente:
 *     ```
       function chunk(arr, chunkSize) {
       var areas = [];
       for (var i=0,len=arr.length; i<len; i+=chunkSize)
       areas.push(arr.slice(i,i+chunkSize));
       return areas.mapster('highlight', render_highlight.key); 
       }
       ```
   
 * Edit: Im trying to load chunks onMouseOut function.
 *     ```
       onMouseout: function(){
       $.each(areas, function(key, render_highlight){
       $(map).mapster('highlight', render_highlight.key);
       }
       }
       ```
   
    -  This topic was modified 7 years, 9 months ago by [andza1](https://wordpress.org/support/users/andza1/).
    -  This topic was modified 7 years, 9 months ago by [andza1](https://wordpress.org/support/users/andza1/).
    -  This topic was modified 7 years, 9 months ago by [andza1](https://wordpress.org/support/users/andza1/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [andza1](https://wordpress.org/support/users/andza1/)
 * (@andza1)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/load-areasarray-in-chunks/#post-10635212)
 * I found a easy solution
 * Just add a setTimeout.
 *     ```
       onMouseout: function(){
       $.each(areas, function(key, render_highlight){
       setTimeout(function() {
       $(map).mapster('highlight', render_highlight.key);
       }, 5 * key)
       });
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Load areas(array) in chunks’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/imagemapper_e1e9f0.svg)
 * [ImageMapper](https://wordpress.org/plugins/imagemapper/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/imagemapper/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/imagemapper/)
 * [Active Topics](https://wordpress.org/support/plugin/imagemapper/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/imagemapper/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/imagemapper/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [andza1](https://wordpress.org/support/users/andza1/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/load-areasarray-in-chunks/#post-10635212)
 * Status: not resolved