Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresponsive script - is it possible to avoid it?

Tags:

jquery

I have a listing with 150 rows and for each row there are three skinned select items.

Because there's heavy processing to be done before displaying each result I get an error saying "A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete." and it refers to jquery.js file.

Is it possible to avoid this error by doing some jQuery work?

Thank you.

like image 666
Psyche Avatar asked May 23 '12 09:05

Psyche


People also ask

What happened with Firefox?

Firefox is still very much alive and well as Mozilla has no plans to stop development of their web browsers for desktop (Windows, macOS, Linux) and mobile versions for iOS and Android. Firefox has been their main product.


1 Answers

You need to split your processing into multiple parts and give the browser some time to do stuff besides them by using a 0 or 1 msec setTimeout.

A very easy method would be using the forEachSeries method of the async library:

async.forEachSeries(yourData, function(item, cb) {
    // process item
    async.nextTick(cb);
});

yourData could be the jQuery object containing your rows, then item will be the DOM element of one row.

like image 163
ThiefMaster Avatar answered Sep 19 '22 13:09

ThiefMaster