Merge request pages call timeago() too often, serious performance issues
In large merge request pages, in Firefox 42, there's lots of calls to setInterval
and resulting function invocations, in my case blocking the entire page for a long time:
I strongly suspect jquery.timeago.js
. There's 210 elements with css class js-timeago
in the page, but an astonishing number of 22384 intervals/timeouts defined. I noticed that after each and every time
element, there's a javascript included
<script>
//<![CDATA[
$('.js-timeago').timeago()
//]]>
</script>
It appears that every invocation sets a new interval for every element defined so far. (That would be 210*211/2 = 22155 defined intervals.)
The documentation to time_ago_with_tooltip
in application_helper.rb
already suggests how to fix this: Only call the javascript method once.
See also: Related jquery.timeago issue. I've patched my local installation's copy accordingly, and the performance issues are gone.