Extremely slow hide / show performance when dealing with a large number of items

I experience terrible performance when I make $ ("# myDiv"). show () and $ ("# myDiv"). hide () only on Safari and Chrome on Mac, all other browsers, including IE6, work fine on PC and Mac, so this is a Webkit problem.

div "myDiv" contains a large number of elements, including many checkboxes, JqueryUI tabs and 3 sliders.

I tried "addClass" instead of show / hide, I tried setting margin -10000 and returning to 0, and none of these things help. Is there any work or is it a limitation of these browsers?

+4
source share
4 answers

Ok, I apologize for that, but it's a mind blowing ....

After a solid 50 JS settings, to no avail, it turns out that my problem was in CSS !!!

After spending a day on this, it turns out that "background-size: 100%;" webkit failed! This is crazy ... Deleting this single line deleted all my crashes.

Again it is very unfortunate to report the wrong problem.

+6
source

This seems to be the already discussed issue of Jquery hide () and show () running too slowly in google chrome . They decided it was a mistake in chrome.

+4
source

You can try the following:

$("#myDiv").css("display", "none"); 
+3
source

Try caching your myDiv by doing var $mydiv = $('#myDiv') , and in your selector just use $myDiv . This will avoid creating a jQuery object every time you want to show or hide.

+2
source

Source: https://habr.com/ru/post/1346777/


All Articles