Jump to content

Spoiler Perf and Render Issues

johnduhart

 

I was noticing poor performance when expanding large spoilers, and the Chrome dev tools confirms that. This Timeline graph is pretty bad.

eD0dkoh.png

 

Diving into the code for the spoiler, I can see this:

 

          , _toggleSpoiler = function(e) {
            var header = $(e.currentTarget);
            var target = $(e.target);
            if (target.is('a:not( [data-action="toggleSpoiler"] )') || (target.closest('a').length && !target.closest('a').is('[data-action="toggleSpoiler"]'))) {
                return;
            }
            e.preventDefault();
            if (header.hasClass('ipsSpoiler_closed')) {
                ips.utils.anim.go('fadeIn', header.siblings());
                header.removeClass('ipsSpoiler_closed').addClass('ipsSpoiler_open').find('span').text(ips.getString('spoilerClickToHide'));
            } else {
                header.siblings().hide();
                header.removeClass('ipsSpoiler_open').addClass('ipsSpoiler_closed').find('span').text(ips.getString('spoilerClickToReveal'));
            }
            e.stopPropagation();
        }

What's happening is that all of the siblings of the spoiler header are being animated individually. This explains the large sink of time being spent in the beginning setup the animations and then in the end receiving completion callbacks. Here's a spoiler with a large number of elements inside of it: So it looks like this only affects older posts. Here's the example I was working off of: 

 

 

The Fix: Wrap spoiler contents in a div. The resulting timeline speaks for itself.

 

Wpe9pCF.png

 

This will also fix the issue with spoiler tags displaying content even when hidden. The cause being that it's only hiding DOM siblings, not the bare text of the spoiler.

 

yg2oCQI.png

 

Link to comment
Share on other sites

Link to post
Share on other sites

I've identified the issue, but I don't think there's much that can be done about it unfortunately.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, colonel_mortis said:

I've identified the issue, but I don't think there's much that can be done about it unfortunately.

I don't understand, what prevents you from changing the output of those older tags?

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, johnduhart said:

I don't understand, what prevents you from changing the output of those older tags?

The posts are being stored as HTML, not BBCode, so the brokenness is permanent (ish).

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×