From 462bb1f66abf239492ee33c60feee3402fe64f77 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 24 Jan 2011 11:18:57 +0100 Subject: [PATCH] Fixes #8098. Use the fast document.head when available. Don't set unneeded "script.type = text/javascript". --- speed/jquery-basis.js | 6 ++---- src/ajax/script.js | 2 +- src/core.js | 6 ++---- src/manipulation.js | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/speed/jquery-basis.js b/speed/jquery-basis.js index fff677643..6fe017c1c 100644 --- a/speed/jquery-basis.js +++ b/speed/jquery-basis.js @@ -524,11 +524,9 @@ jQuery.extend({ if ( data && rnotwhite.test(data) ) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, + var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement, script = document.createElement("script"); - script.type = "text/javascript"; - if ( jQuery.support.scriptEval ) { script.appendChild( document.createTextNode( data ) ); } else { @@ -5060,7 +5058,7 @@ jQuery.extend({ // If we're requesting a remote document // and trying to load JSON or Script with a GET if ( s.dataType === "script" && type === "GET" && remote ) { - var head = document.getElementsByTagName("head")[0] || document.documentElement; + var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; var script = document.createElement("script"); script.src = s.url; if ( s.scriptCharset ) { diff --git a/src/ajax/script.js b/src/ajax/script.js index 731f5b609..34ddd0466 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -34,7 +34,7 @@ jQuery.ajaxTransport( "script", function(s) { if ( s.crossDomain ) { var script, - head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement; + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; return { diff --git a/src/core.js b/src/core.js index 915ac6ba4..2e6347236 100644 --- a/src/core.js +++ b/src/core.js @@ -574,10 +574,8 @@ jQuery.extend({ if ( data && rnotwhite.test(data) ) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; + var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, + script = document.createElement( "script" ); if ( jQuery.support.scriptEval() ) { script.appendChild( document.createTextNode( data ) ); diff --git a/src/manipulation.js b/src/manipulation.js index 19a6c22ba..841447fa2 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -7,7 +7,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rtbody = /", "" ], -- 2.39.5