View Issue Details

IDProjectCategoryView StatusLast Update
0013285mantisbtperformancepublic2015-09-11 11:29
Reportercarpii Assigned Tosyncguru  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.0-beta.1 
Target Version1.3.0-beta.3Fixed in Version1.3.0-beta.3 
Summary0013285: Move script inclusions from HEAD to document footer
Description

Since mantis imports jquery and jquery.ui in via HEAD, this causes the browser to block until both scripts have been downloaded and parsed

By moving all scripts from the HEAD tag into the document footer, this creates a dramatic improvement on the perceived rendering time of all mantis pages.

I have done testing with this, and believe it causes no side effects since $document.ready() takes care of it

I have attached a git patch, sorry Im unable to submit a proper pull request

Tagspatch
Attached Files
head_to_toe.txt (2,105 bytes)   
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
head_to_toe.txt (2,105 bytes)   

Relationships

related to 0019932 closedvboctor Load jquery from CDN 
related to 0020081 closeddregad Moving JS to bottom is causing 'ReferenceError: jQuery is not defined' errors 
related to 0020088 closeddregad slow hiding of project-selector, filters 

Activities

syncguru

syncguru

2015-05-03 21:26

developer   ~0050690

Pull request: https://github.com/mantisbt/mantisbt/pull/605

dregad

dregad

2015-09-07 10:56

developer   ~0051385

This causes a regression for plugins relying on jQuery, see 0020081

Related Changesets

MantisBT: master 4a81ef15

2015-05-03 17:22

syncguru

Committer: dregad


Details Diff
Move script inclusions from HEAD to document footer

Fixes 0013285: Move script inclusions from HEAD to document footer
Affected Issues
0013285
mod - core/html_api.php Diff File

MantisBT: master 8d7ea37e

2015-09-11 06:03

dregad


Details Diff
Revert move-js-to-footer

This change (see issue 0013282) introduced several regressions.

This reverts commit 2dbc86b10d10495f1312b781fe0a3519a0d7152a, reversing
changes made to aa9b4f8ad7908325633542840805c4c854adb1f1.

Fixes 0020081, 0020088
Affected Issues
0013285, 0020081, 0020088
mod - core/html_api.php Diff File