Performance Optimization Tips for Some Jquery Commands in IE

Show / hide the thumb grid in IE8 is very slow.

I have a thumb that works with the category attribute on each thumb and some buttons to show different categories. The code below handles the show / hide of the thumbs, but in IE it is very slow and sometimes it calls "A script slow" -warning. I think there is no need to claim that this works well in all other browsers.

My question is: can you help with some performance tips? Perhaps even hinting at whether it makes sense to rewrite this bit to pure Javascript?

$('#cat-tab .categories-list a').live('click', function() {
        var $this = $(this);
        var $target = $('#cat-tab .video-results');
        var $text = $.trim($('span', $this).text());
        $scroll = $(window).scrollTop();

        $('#cat-tab .categories-list a').removeClass('active');
        $this.addClass('active');

        $('#cat-tab .video-results .channel').removeClass('hidden');
        if($text != 'All') {
            $('#cat-tab .video-results .channel[rel!="'+$text+'"]').addClass('hidden');
        }
        $.rePage(true);

        return false;
    });
+3
1

, script, :

#categories .channel { display: none; }
#categories.category-all .channel { display: block; }
#categories.category-1 .channel-1 { display: block; }
#categories.category-2 .channel-2 { display: block; }
#categories.category-3 .channel-3 { display: block; }
#categories.category-4 .channel-4 { display: block; }

className ancestor #categories, / , .

+3

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


All Articles