admin管理员组

文章数量:1410724

I have created a Drupal website that uses Openlayers to display maps. In one of these maps there are some "Filters" which the user can use to dynamically change the data shown in the map. The data are related to countries are shown as bubbles over the countries. The bubbles are drawn using Openlayers' API. A good amount of calculations go behind the scene while filters are selected. I have used setTimeout to avoid long running loops. The filters work fine. However, after a number of filters are clicked (e.g. if 12 filters are clicked), if the user tries to move to another page by clicking a link, in IE7 and IE8 the following error shows -

"Stop running this script?

A script on this page is causing your web browser to run slowly. If it continues to run, your puter might bee unresponsive."

This error does not show in any other browser and does not show in IE7, 8 until a link is clicked. Any pointer in this regard will be highly appreciated.

UPDATE : The problem was in OpenLayers' event cache. OpenLayers's clears the event cache in the window unload event and this was getting stuck in IE7 and IE8 (I am not sure why). So far I have been able to solve the issue when user clicks another link, by calling OpenLayers.Event.unloadCache() on click of normal links.

I have created a Drupal website that uses Openlayers to display maps. In one of these maps there are some "Filters" which the user can use to dynamically change the data shown in the map. The data are related to countries are shown as bubbles over the countries. The bubbles are drawn using Openlayers' API. A good amount of calculations go behind the scene while filters are selected. I have used setTimeout to avoid long running loops. The filters work fine. However, after a number of filters are clicked (e.g. if 12 filters are clicked), if the user tries to move to another page by clicking a link, in IE7 and IE8 the following error shows -

"Stop running this script?

A script on this page is causing your web browser to run slowly. If it continues to run, your puter might bee unresponsive."

This error does not show in any other browser and does not show in IE7, 8 until a link is clicked. Any pointer in this regard will be highly appreciated.

UPDATE : The problem was in OpenLayers' event cache. OpenLayers's clears the event cache in the window unload event and this was getting stuck in IE7 and IE8 (I am not sure why). So far I have been able to solve the issue when user clicks another link, by calling OpenLayers.Event.unloadCache() on click of normal links.

Share Improve this question edited Apr 5, 2012 at 10:54 Abhijit asked Jun 28, 2011 at 11:12 AbhijitAbhijit 8955 silver badges11 bronze badges 1
  • If you put a link to the page we can take a look to the code. – Rodrigo Commented Jun 28, 2011 at 12:26
Add a ment  | 

2 Answers 2

Reset to default 5

jQuery can be very resource expensive. The articles linked bellow gives you 10 good advices to perform better your jQuery applications. The most useful for me (I had the same problem a month ago) was to replace $.each() with traditional for lops and to replace extensive DOM construction with jquery templates. Also the use of ID instead of classes and to give a context for the selectors, selector caching, and so on.

This list is ordered using my own criteria of "usefulness" in the advices.

  1. 10 ways to instantly increase your jquery performance

  2. improve your jquery 25 excellent tips

  3. 10 advanced jquery performance tuning tips from paul irish

  4. 8 jquery performance tips

You need to optimize your client script. Please refer to answers here.

本文标签: