this works fine for me...<br>the trick is to process buckets 25 dates each time, and delaying the execution of the rest 10ms which gives some time to the browser to handle other threads.<br><br>Not the best thing, best would be handle these manipulation at backend side.<br>
<br><span style="font-family:courier new,monospace">return function() {<br>        var ageclass = /\\bage\\b/,<br>            dateclass = /\\bdate\\b/,<br>            nodes = document.getElementsByClassName ? document.getElementsByClassName('age')<br>
                                                    : document.getElementsByTagName('*'),<br>            length = nodes.length, i=0;<br>        // delayed execution for responsiveness<br>        !function  process() {<br>
            // each time process only some dates<br>            for (var b = 0; b < 25; b++) {<br>                var node = nodes[i++];<br>                // we may destroy nodes as we process them<br>                if (node && node.textContent) {<br>
                    var classes = node.className;<br>                    if (document.getElementsByClassName || ageclass.test(classes)) {<br>                        var agevalue = age(node.textContent);<br>                        if (dateclass.test(classes)){<br>
                            // We want both: date + (age)<br>                            node.textContent += ' ('+agevalue+')';<br>                        } else {<br>                            node.textContent = agevalue;<br>
                        }<br>                    }<br>                }<br>            }<br>            if (i < length) setTimeout(process, 10);<br>        }();<br>    };</span><br><br><br clear="all"> Martin Scotta<br>

<br><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 5:41 PM, Matt Mackall <span dir="ltr"><<a href="mailto:mpm@selenic.com" target="_blank">mpm@selenic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, 2012-09-25 at 12:16 -0300, Martin Scotta wrote:<br>
> Hi hg dev,<br>
> With the latest update (version 2.3.1+20120908) the command hg serve became<br>
> completely unusable due to a bad-written javascript function.<br>
> My browser complains about some function taking too long to finish -- I'm<br>
> using latest Firefox on a brand new Retina MacBook Pro<br>
><br>
> The function process_dates (mercurial.js) traverses the ENTIRE dom,<br>
<br>
</div>Usually, this is fine because pages like the index are very small. But<br>
apparently on large files (with no dates to process!) this can take<br>
quite a while. For instance, i18n/ru.po in the Mercurial repo (25k<br>
lines) takes 9s to fully load, according to Firebug.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Mathematics is the supreme nostalgia of our time.<br>
<br>
<br>
</font></span></blockquote></div><br>