Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8836

Moving Auto-Generated Inline JavaScript to Before The Closing tag

$
0
0
Hi There,I've been trying to figure out how to move certain render blocking elements to the footer of HTML which I've mostly been successful in doing.The PMC Portal Engine Resource Combiner (http://devnet.kentico.com/marketplace/utilities/portal-engine-resource-combiner) has been a massive help in combining the WebResource.axd and ScriptResource.axd files into 1 file. I added a line of code to move the script tag referencing the combined axd file to before the closing @/body which I've been plagued with JS errors (for all the right reasons):(index):75 Uncaught ReferenceError: Sys is not defined(…) (index):315 Uncaught ReferenceError: Sys is not defined(…) (index):320 Uncaught ReferenceError: Sys is not defined(…) (index):333 Uncaught ReferenceError: WebForm_InitCallback is not defined(…) Here's some references to the lines above:Line 75: //@![CDATA[ Sys.WebForms.PageRequestManager._initialize('manScript', 'form', ['tctxM',''], [], [], 90, ''); //]]@ Line 315://@![CDATA[ (function() {var fn = function() {$get(@manScript_HiddenField@).value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();//]]@ Line 320://@![CDATA[ if (typeof(Sys.Browser.WebKit) == 'undefined') { Sys.Browser.WebKit = {}; } if (navigator.userAgent.indexOf('WebKit/') @ -1) { Sys.Browser.agent = Sys.Browser.WebKit; Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]); Sys.Browser.name = 'WebKit'; } //]]@ Line 333://@![CDATA[ WebForm_InitCallback(); theForm.oldSubmit = theForm.submit; theForm.submit = WebForm_SaveScrollPositionSubmit; theForm.oldOnSubmit = theForm.onsubmit; theForm.onsubmit = WebForm_SaveScrollPositionOnSubmit; //]]@ Line 354:@script src=@/axd/760d5979-3f77-485a-b59a-9b98ccbac6a9/combiner.axd@ type=@text/javascript@@@/script@@/body@ In an ideal world what I'm after is the script reference to combiner.axd on line 354 before the 4 script tags followed by the closing tag. That'd surely resolve the JS errors? Is there any reason they cannot be moved?My PageSpeed Insights mobile speed score is:80% before combining the axd files,85% after combining the axd files,100% after combining the axd files and moving to before the tagSo you can see why I'm keen to find a solution. If anybody can help that'd be much appreciated.Thanks in advance,Andy

Viewing all articles
Browse latest Browse all 8836

Trending Articles