As mentioned in css and javascript aggregation the current
ordering of Javascript files in toggle,
relativedate and recentchangesdiff is
incorrect: Javascript files get loaded before the main content and may
even be loaded before the <html>
tag for templates that indent the
<body>
tag with whitespace.
According to the best practices Javascript resources should be presented to browsers after CSS, and "after the fold" (ATF) according to the best practices. This allows the browser to download Javascript files in parallel.
I have pushed a simple patch which fixes this issue by including
Javascript on the closing </body>
tag instead of the opening tag.
It also improves the regex to tolerate spaces before the </body>
tag,
as some templates have (proper) indentation for the tag.