Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Move all js to footer (Trac #2718) #2718
Original ticket http://trac.elgg.org/ticket/2718 on 40938946-03-15 by ewinslow, assigned to unknown.
Elgg version: 1.7
It makes a huge difference in page render time (hundreds of milliseconds) to move scripts from the head to the footer of the page. We should really try to do this if at all possible.
At the very least, they definitely need to come after the CSS.
trac user hellekin wrote on 40940413-01-15
I recommend YSlow, the Yahoo! extension to Firebug to testdrive page's speed and find ways to optimize it.
ewinslow wrote on 42324880-12-08
At the very least we could make the footer the default location, forcing plugins to move the js up if that's what they really need to do.
Chrome has a very nifty feature that allows you to do network throttling to simulate very slow environments. I decided to try 2G... (Lots of people around the world are on 2G, or just imagine a flaky 3G/4G, etc.)
The community site takes 15 seconds to load with an unprimed cache (you can disable caching in dev tools).
Thankfully, once you turn on the cache, it renders something in under 1s on 2G! This is great news, but just means we absolutely need to defer-load the JS.
One trivial step we could take is just make turn on the defer attribute by default for all the scripts that we currently load. They are guaranteed to execute in order and only after the document has loaded, but will download in parallel, which is great.
This would also help us root out all the inline scripts currently in core by causing them to fail., which we would then HAVE to fix before releasing 2.0 final.
@Elgg/owners How do people feel about making this massively breaking change? Haven't heard anything from the rest of you.
As stated above, I'd like to just make all register/load scripts as "defer" so that this happens more or less automatically with minimal changes.
IMO it's critical for performance going forward. The scripts in head thing is just ridiculously out of control.