From 2eb0e00209bed4960a29ca2bf66aa7b063f6354e Mon Sep 17 00:00:00 2001
From: Carpii <p.chapman.uk@gmail.com>
Date: Thu, 1 Sep 2011 23:34:12 +0100
Subject: [PATCH] Move scripts to document footer instead of head,
 dramatically improves percieved rendering time

---
 core/html_api.php |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/core/html_api.php b/core/html_api.php
index 66a946d..152c88f 100644
--- a/core/html_api.php
+++ b/core/html_api.php
@@ -419,17 +419,8 @@ function require_js( $p_script_path ) {
  * @return null
  */
 function html_head_javascript() {
-	if ( config_get( 'use_javascript' ) ) {
-		global $g_scripts_included;
-		echo "\t<script type=\"text/javascript\" src=\"" . helper_mantis_url( 'javascript_config.php' ) . '"></script>' . "\n";
-		echo "\t<script type=\"text/javascript\" src=\"" . helper_mantis_url( 'javascript_translations.php' ) . '"></script>' . "\n";
-		html_javascript_link( 'jquery.js' );
-		html_javascript_link( 'jquery-ui.js' );
-		html_javascript_link( 'common.js' );
-		foreach ( $g_scripts_included as $t_script_path ) {
-			html_javascript_link( $t_script_path );
-		}
-	}
+	// 2011/09/01.CARP - Move javascript inclusions into html_body_end()
+	return;
 }
 
 /**
@@ -690,6 +681,20 @@ function html_footer( $p_file = null ) {
  * @return null
  */
 function html_body_end() {
+
+	// 2011/09/01.CARP - move selected javascripts out of HEAD and into bottom of document
+	if ( config_get( 'use_javascript' ) ) {
+		global $g_scripts_included;
+		echo "\t<script type=\"text/javascript\" src=\"" . helper_mantis_url( 'javascript_config.php' ) . '"></script>' . "\n";
+		echo "\t<script type=\"text/javascript\" src=\"" . helper_mantis_url( 'javascript_translations.php' ) . '"></script>' . "\n";
+		html_javascript_link( 'jquery.js' );
+		html_javascript_link( 'jquery-ui.js' );
+		html_javascript_link( 'common.js' );
+		foreach ( $g_scripts_included as $t_script_path ) {
+			html_javascript_link( $t_script_path );
+		}
+	}
+
 	event_signal( 'EVENT_LAYOUT_BODY_END' );
 
 	echo '</div>', "\n";
-- 
1.7.6
