开发者

Adding and removing inputs via jQuery's remove(), but page gets slow, how to free memory?

开发者 https://www.devze.com 2022-12-30 08:36 出处:网络
I\'m dynamically adding a lot of input fields through jQuery but the page gets really slow when reaching 200+ inputs (think of the page like a html excel sheet). This is fine really because this scena

I'm dynamically adding a lot of input fields through jQuery but the page gets really slow when reaching 200+ inputs (think of the page like a html excel sheet). This is fine really because this scenario is not very common. However, when I dynamically remove the input fields from the page using jQuery's htmlObj.remove() function, the page is still slow as if there were hundreds of inputs still there. Is there any way to explicitly free memory in jQuery/javascript?

My experience with this is from using Firefox. When using Internet Explorer, the page is really slow from the start but that's a whole different story.

The technique I'm using is called event delegation as it's supposed to be the least memory resourceful approach, compared to having all handlers explicitly bound to every object on the page.

Sadly, blur and focus events do not work with event delegation and therefore I need to bind these to every input. This could possibly be the memory hog here. Also, in Firefox it seems I can't use checkboxes for 'changed' or 'key[down|up]' events in ev开发者_如何转开发ent delegation as these checkbox events do not bubble up to the document. Here binding explicitly too.

Anyone can share some experience with this? Can't really show a demo right now as the site has not been launched yet.

Thx.


read this, I'm sure it will help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号