Move comment-reply to the bottom of the page
|Reported by:||josephscott||Owned by:||nacin|
So I did some tests. I removed the
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
in header.php and replaced it with
<?php if ( is_singular() ) wp_print_scripts( 'comment-reply' ); ?>
at the very bottom of footer.php, just after the wp_footer() call and before the closing BODY and HTML tags. The idea being to allow browsers to load the comment-reply JS as late as possible.
I then used webpagetest.org to run load tests (IE8). Here's the waterfall chart before my changes - http://www.webpagetest.org/result/100318_63M1/1/details/ - and after my changes - http://www.webpagetest.org/result/100318_63M3/1/details/
You'll notice that the after chart has more parallel downloads of page resources. Specifically in the before chart all other downloads are blocking until it finished getting comment-reply.js.
I also looked at the charts in Chrome (resource inspector) and Firefox (firebug), both show similar results, with more parallel downloads happening with comment-reply JS moved to footer.php.
I haven't seen any downsides to this move so far. If this breaks something or causes other problems let's see what we can do to deal with them. In the mean time I'm including a simple patch to make this change.
Change History (17)
- Keywords needs-patch added; has-patch removed
- Milestone changed from 3.0 to Future Release
comment:12 obenland — 13 months ago
- Component changed from Bundled Theme to Performance
- Keywords has-patch added; needs-patch removed
- Milestone changed from WordPress.org to Future Release
comment:13 nacin — 3 months ago
- Component changed from Performance to Themes
- Focuses performance added
- Milestone changed from Future Release to 3.9