<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Where to include JavaScript files in a document</title>
	<atom:link href="http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/</link>
	<description>Web development and Internet trends</description>
	<lastBuildDate>Sat, 20 Mar 2010 20:09:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Steve Repetti</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-574094</link>
		<dc:creator>Steve Repetti</dc:creator>
		<pubDate>Sun, 19 Apr 2009 12:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-574094</guid>
		<description>I actually use both methods as needed.  In general, my JS goes up top and is always optimized (consolidating multiple JS files into one -- I do the same thing with CSS files too).  That way, if I need inline stuff as the page loads it is available.  If I need to then trigger something after the page is loaded, I hook to the onload event. 

Finally, if I want to render something before the page finishes loading, like a marquee or news scroller, I put the code either at the end or just below the DOM elements that it requires.  Provides a great performance balance!

Steve Repetti
www.radwebtech.com, www.scrapplet.com, www.xwinlib.com, www.dataportability.org</description>
		<content:encoded><![CDATA[<p>I actually use both methods as needed.  In general, my JS goes up top and is always optimized (consolidating multiple JS files into one &#8212; I do the same thing with CSS files too).  That way, if I need inline stuff as the page loads it is available.  If I need to then trigger something after the page is loaded, I hook to the onload event. </p>
<p>Finally, if I want to render something before the page finishes loading, like a marquee or news scroller, I put the code either at the end or just below the DOM elements that it requires.  Provides a great performance balance!</p>
<p>Steve Repetti<br />
<a href="http://www.radwebtech.com" rel="nofollow">http://www.radwebtech.com</a>, <a href="http://www.scrapplet.com" rel="nofollow">http://www.scrapplet.com</a>, <a href="http://www.xwinlib.com" rel="nofollow">http://www.xwinlib.com</a>, <a href="http://www.dataportability.org" rel="nofollow">http://www.dataportability.org</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thank you for 2008 - Happy New Year! - Robert&#8217;s talk - Web development and Internet trends</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-492995</link>
		<dc:creator>Thank you for 2008 - Happy New Year! - Robert&#8217;s talk - Web development and Internet trends</dc:creator>
		<pubDate>Tue, 30 Dec 2008 21:40:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-492995</guid>
		<description>[...] Where to include JavaScript files in a document [...]</description>
		<content:encoded><![CDATA[<p>[...] Where to include JavaScript files in a document [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Why inline CSS and JavaScript code is such a bad thing &#124; How2Pc</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-489203</link>
		<dc:creator>Why inline CSS and JavaScript code is such a bad thing &#124; How2Pc</dc:creator>
		<pubDate>Tue, 23 Dec 2008 07:29:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-489203</guid>
		<description>[...] code, and one JavaScript block located at the bottom of their HTML code (read more about why in Where to include JavaScript files in a document) and just have id and class attributes to connect that code [...]</description>
		<content:encoded><![CDATA[<p>[...] code, and one JavaScript block located at the bottom of their HTML code (read more about why in Where to include JavaScript files in a document) and just have id and class attributes to connect that code [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2008-11-29 &#124; Yostivanich.com</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-480557</link>
		<dc:creator>links for 2008-11-29 &#124; Yostivanich.com</dc:creator>
		<pubDate>Sat, 29 Nov 2008 15:04:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-480557</guid>
		<description>[...] Where to include JavaScript files in a document - Robertâ€™s talk - Web development and Internet tre... Include that JavaScript in the bottom of the page. (tags: javascript webdevelopment performance) [...]</description>
		<content:encoded><![CDATA[<p>[...] Where to include JavaScript files in a document &#8211; Robertâ€™s talk &#8211; Web development and Internet tre&#8230; Include that JavaScript in the bottom of the page. (tags: javascript webdevelopment performance) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470250</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 05 Nov 2008 13:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470250</guid>
		<description>exacly how flash AS has been optimized.   with AS3 you can now only import classes that are needed. the same principle sould be used with larger JS libraries.</description>
		<content:encoded><![CDATA[<p>exacly how flash AS has been optimized.   with AS3 you can now only import classes that are needed. the same principle sould be used with larger JS libraries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470245</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 05 Nov 2008 13:05:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470245</guid>
		<description>you can also use javascript to include other JS. with an if statment, and  include by document.write concating the include w/two strings.</description>
		<content:encoded><![CDATA[<p>you can also use javascript to include other JS. with an if statment, and  include by document.write concating the include w/two strings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470243</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 05 Nov 2008 13:02:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470243</guid>
		<description>to add to that.  I know what someone is going to say already.  the dom will not be ready until the body loads -

instead of a complete dom-ready - use a targeted tag id or on load function not on the body can be an image or whatever to call the function.

also note that you can have JS includes anywhere in the document apply them as needed.

note: The header JS will only be slower on initial page load after it&#039;s been cached, it&#039;s faster to have it in the header.  So it would be ideal to have &#039;some&#039; script in the header section.  

as always with these type of &#039;what is better answers&#039; - it depends on the app/ page itself.</description>
		<content:encoded><![CDATA[<p>to add to that.  I know what someone is going to say already.  the dom will not be ready until the body loads -</p>
<p>instead of a complete dom-ready &#8211; use a targeted tag id or on load function not on the body can be an image or whatever to call the function.</p>
<p>also note that you can have JS includes anywhere in the document apply them as needed.</p>
<p>note: The header JS will only be slower on initial page load after it&#8217;s been cached, it&#8217;s faster to have it in the header.  So it would be ideal to have &#8217;some&#8217; script in the header section.  </p>
<p>as always with these type of &#8216;what is better answers&#8217; &#8211; it depends on the app/ page itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470239</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 05 Nov 2008 12:45:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-470239</guid>
		<description>If you are looking for a definitive answer in which is better then you would be mistaken by doing so.
 
The correct answer is to use JavaScript in the header and includes inside the document and sometimes both.

In the header initialize variables and functions that are essential for initial layout, 
and only the â€˜basicâ€™ page functionality for your application.  There are dom-ready scripts that work.

The problem is that so many are trying to use these giant JS libraries. 
These libraries for building RIAs are far from optimal and not nearly as modular as they should be.  I would think best practice would be to include JS files as needed through out the document in the form of progressive loading and progressive execution. Only including the parts that are needed for the current loaded content, and interchanging loading XHTML and JavaScript only as it is needed.</description>
		<content:encoded><![CDATA[<p>If you are looking for a definitive answer in which is better then you would be mistaken by doing so.</p>
<p>The correct answer is to use JavaScript in the header and includes inside the document and sometimes both.</p>
<p>In the header initialize variables and functions that are essential for initial layout,<br />
and only the â€˜basicâ€™ page functionality for your application.  There are dom-ready scripts that work.</p>
<p>The problem is that so many are trying to use these giant JS libraries.<br />
These libraries for building RIAs are far from optimal and not nearly as modular as they should be.  I would think best practice would be to include JS files as needed through out the document in the form of progressive loading and progressive execution. Only including the parts that are needed for the current loaded content, and interchanging loading XHTML and JavaScript only as it is needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-410330</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Mon, 08 Sep 2008 01:08:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-410330</guid>
		<description>I like the js at the bottom of the document. I don&#039;t know if this is kosher, but it works even if you put if OUTSIDE of the closing </description>
		<content:encoded><![CDATA[<p>I like the js at the bottom of the document. I don&#8217;t know if this is kosher, but it works even if you put if OUTSIDE of the closing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-258400</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Sat, 26 Apr 2008 22:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-258400</guid>
		<description>Andreas,

Yes, statistics scripts should always be at the bottom, no matter what.

Morgan

Thanks for the tip! Interesting tool!

Diego,

Event delegation can be a good solution, and is in general the way to work with events. However, just as you say, many times people use a JavaScript library to apply events, and then that library need to be included before the event is applied anyway (unless one uses separate code for applying just that specific event, but then in turn, you have multiple places and ways to handle events, which isn&#039;t good either).

So, I&#039;m just not sure it&#039;s the best solution either. It&#039;s tough shit finding a good solution here. :-)

When it comes to event delegation (and your IEContentLoaded solution and &lt;code&gt;doScroll&lt;/code&gt;, which is funky stuff :-) ), I know you have good code and ideas. I guess it all depends on what level you want to take event delegation too, but in general I do propose to people to have an event on the containing element, and then work with what element was the actual target.

Outtanames999,

To be honest, I don&#039;t really know about their Flash files, but when it comes to HTML, CSS and JavaScript, I personally think their research has lead to a lot of great advice and practices.</description>
		<content:encoded><![CDATA[<p>Andreas,</p>
<p>Yes, statistics scripts should always be at the bottom, no matter what.</p>
<p>Morgan</p>
<p>Thanks for the tip! Interesting tool!</p>
<p>Diego,</p>
<p>Event delegation can be a good solution, and is in general the way to work with events. However, just as you say, many times people use a JavaScript library to apply events, and then that library need to be included before the event is applied anyway (unless one uses separate code for applying just that specific event, but then in turn, you have multiple places and ways to handle events, which isn&#8217;t good either).</p>
<p>So, I&#8217;m just not sure it&#8217;s the best solution either. It&#8217;s tough shit finding a good solution here. <img src='http://robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>When it comes to event delegation (and your IEContentLoaded solution and <code>doScroll</code>, which is funky stuff <img src='http://robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ), I know you have good code and ideas. I guess it all depends on what level you want to take event delegation too, but in general I do propose to people to have an event on the containing element, and then work with what element was the actual target.</p>
<p>Outtanames999,</p>
<p>To be honest, I don&#8217;t really know about their Flash files, but when it comes to HTML, CSS and JavaScript, I personally think their research has lead to a lot of great advice and practices.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Outtanames999</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-258124</link>
		<dc:creator>Outtanames999</dc:creator>
		<pubDate>Sat, 26 Apr 2008 16:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-258124</guid>
		<description>I wouldn&#039;t look to Yahoo for best practices on page loads - they&#039;ve got the slowest pages on the net!

In spite of the great deal of attention they have paid to optimizing HTML and JS and PHP, they are at the mercy of bloated Flash files and no amount of code text optimization can possibly counteract that, which Yahoo has all but admitted.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t look to Yahoo for best practices on page loads &#8211; they&#8217;ve got the slowest pages on the net!</p>
<p>In spite of the great deal of attention they have paid to optimizing HTML and JS and PHP, they are at the mercy of bloated Flash files and no amount of code text optimization can possibly counteract that, which Yahoo has all but admitted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diego Perini</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-257479</link>
		<dc:creator>Diego Perini</dc:creator>
		<pubDate>Sat, 26 Apr 2008 01:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-257479</guid>
		<description>I personally put scripts in the head section as for specs but the comments above depict other situation for preferring this.

Anyway the best pratice for the &quot;clicked to early&quot; problem is to use event delegation, this allows avoiding to wait for an &quot;onload&quot; event so the event can be added as soon as
the script starts (dynamically bound to new elements as they enter the DOM).

As a last resort if I have to wait for the entire HTML to be completely loaded I use my &quot;ContentLoaded.js&quot; to correctly handle the missing method for IE. The &quot;doScroll(&#039;left&#039;)&quot; trick for IE is great for these situations.

There may be scripts that can be loaded later through asynchronous &quot;lazy loading&quot; if the complete framework is too big. This may also be a reason to load all the pieces at the time they are needed. However a core script is necessary in the head to allow for &quot;early page enlivenment&quot; and to let the users click on buttons as soon as they see them appear.

Robert you may have a look at my lab site for &quot;Event Delegates&quot; you may be tempted to add something like that to your powerful DomAssistant, sources are on Google Code.

Diego Perini</description>
		<content:encoded><![CDATA[<p>I personally put scripts in the head section as for specs but the comments above depict other situation for preferring this.</p>
<p>Anyway the best pratice for the &#8220;clicked to early&#8221; problem is to use event delegation, this allows avoiding to wait for an &#8220;onload&#8221; event so the event can be added as soon as<br />
the script starts (dynamically bound to new elements as they enter the DOM).</p>
<p>As a last resort if I have to wait for the entire HTML to be completely loaded I use my &#8220;ContentLoaded.js&#8221; to correctly handle the missing method for IE. The &#8220;doScroll(&#8216;left&#8217;)&#8221; trick for IE is great for these situations.</p>
<p>There may be scripts that can be loaded later through asynchronous &#8220;lazy loading&#8221; if the complete framework is too big. This may also be a reason to load all the pieces at the time they are needed. However a core script is necessary in the head to allow for &#8220;early page enlivenment&#8221; and to let the users click on buttons as soon as they see them appear.</p>
<p>Robert you may have a look at my lab site for &#8220;Event Delegates&#8221; you may be tempted to add something like that to your powerful DomAssistant, sources are on Google Code.</p>
<p>Diego Perini</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Morgan Roderick</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-257258</link>
		<dc:creator>Morgan Roderick</dc:creator>
		<pubDate>Fri, 25 Apr 2008 19:14:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-257258</guid>
		<description>Or you could just test it out yourself, with your favourite browsers at:

http://stevesouders.com/cuzillion/

My new favourite tool :D</description>
		<content:encoded><![CDATA[<p>Or you could just test it out yourself, with your favourite browsers at:</p>
<p><a href="http://stevesouders.com/cuzillion/" rel="nofollow">http://stevesouders.com/cuzillion/</a></p>
<p>My new favourite tool <img src='http://robertnyman.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Rydberg</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256964</link>
		<dc:creator>Andreas Rydberg</dc:creator>
		<pubDate>Fri, 25 Apr 2008 11:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256964</guid>
		<description>I haven&#039;t read all the other comments, so I might be repeating some things that other said.

I&#039;ve looked at many of the videos from Yahoo Developer&#039;s area. And they contridict themselves somewhat. But one should not blindly go with one side or the other, just use common sense is my advice.

In one video the guy said that splitting large Javascript-files into smaller logical parts. This would make the browsing experience better, because the user don&#039;t need to download a lot of code that is useless on the current page.

In the next video another guy said that you should put everything in one large file, causing less HTTP-requests.

Personally, I use both, depending on situation and where it&#039;s logical to have bigger or smaller files.

To stay on topic I usually put most scripts in the head, but when I can put them in the bottom of document - I do it. Specially if you use Google Analytics and similar on your site/app, they can make pages halt for several seconds.

One other thing; if you have scripts in smaller parts and you have a start page (after user logs in), then you can preload scripts by putting them in the bottom of the document.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t read all the other comments, so I might be repeating some things that other said.</p>
<p>I&#8217;ve looked at many of the videos from Yahoo Developer&#8217;s area. And they contridict themselves somewhat. But one should not blindly go with one side or the other, just use common sense is my advice.</p>
<p>In one video the guy said that splitting large Javascript-files into smaller logical parts. This would make the browsing experience better, because the user don&#8217;t need to download a lot of code that is useless on the current page.</p>
<p>In the next video another guy said that you should put everything in one large file, causing less HTTP-requests.</p>
<p>Personally, I use both, depending on situation and where it&#8217;s logical to have bigger or smaller files.</p>
<p>To stay on topic I usually put most scripts in the head, but when I can put them in the bottom of document &#8211; I do it. Specially if you use Google Analytics and similar on your site/app, they can make pages halt for several seconds.</p>
<p>One other thing; if you have scripts in smaller parts and you have a start page (after user logs in), then you can preload scripts by putting them in the bottom of the document.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Nyman</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256899</link>
		<dc:creator>Robert Nyman</dc:creator>
		<pubDate>Fri, 25 Apr 2008 09:19:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256899</guid>
		<description>Thanks for great comments! Apparently there are many aspects to this, and no one-solution-fits-all is out there. And for high-performance web sites, NICCAI and Remy, with the &lt;code&gt;earlyClickHandler&lt;/code&gt; solution, pose interesting ideas which aren&#039;t best practice, but rather about actually making things work the best way they can in real life.

Alternative cases might be sufficiently efficient if you compress all your JavaScript files into one, compress them and gzip them, and then include them in the &lt;code&gt;head&lt;/code&gt; part of the document.

Paul, AndrÃ©,

I&#039;m glad you liked the references in the post... :-)</description>
		<content:encoded><![CDATA[<p>Thanks for great comments! Apparently there are many aspects to this, and no one-solution-fits-all is out there. And for high-performance web sites, NICCAI and Remy, with the <code>earlyClickHandler</code> solution, pose interesting ideas which aren&#8217;t best practice, but rather about actually making things work the best way they can in real life.</p>
<p>Alternative cases might be sufficiently efficient if you compress all your JavaScript files into one, compress them and gzip them, and then include them in the <code>head</code> part of the document.</p>
<p>Paul, AndrÃ©,</p>
<p>I&#8217;m glad you liked the references in the post&#8230; <img src='http://robertnyman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tino Zijdel</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256798</link>
		<dc:creator>Tino Zijdel</dc:creator>
		<pubDate>Fri, 25 Apr 2008 06:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256798</guid>
		<description>Head, definitely. I want to apply JS behaviour as soon as possible to avoid confusing users with different behaviour when the page is not fully loaded so I use inline functioncalls right after the sections the behaviour should be applied to. Some people might call that a sin in itself but obviously they have never created a large website themselves...

Splitting up the JS functions into a file that is necessary beforehand and one that can be loaded afterwards only results in an extra HTTP request on first hit so is also less than optimal.

As for JS optimization: we use HTTP compression and are considering minification although that will only squeeze an insignificant extra bytes out of the size on the wire. Using f.i. Dean&#039;s packer is far less optimal and requires the client to &#039;unpack&#039; the contents on every pageview which is actually more of a performance drain than a gain.</description>
		<content:encoded><![CDATA[<p>Head, definitely. I want to apply JS behaviour as soon as possible to avoid confusing users with different behaviour when the page is not fully loaded so I use inline functioncalls right after the sections the behaviour should be applied to. Some people might call that a sin in itself but obviously they have never created a large website themselves&#8230;</p>
<p>Splitting up the JS functions into a file that is necessary beforehand and one that can be loaded afterwards only results in an extra HTTP request on first hit so is also less than optimal.</p>
<p>As for JS optimization: we use HTTP compression and are considering minification although that will only squeeze an insignificant extra bytes out of the size on the wire. Using f.i. Dean&#8217;s packer is far less optimal and requires the client to &#8216;unpack&#8217; the contents on every pageview which is actually more of a performance drain than a gain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remy Sharp</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256606</link>
		<dc:creator>Remy Sharp</dc:creator>
		<pubDate>Thu, 24 Apr 2008 21:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256606</guid>
		<description>@Andrea - I specifically apply the onclick (nasty, but only used in desperate situations) on the links that should hook JS actions that I knew were required. i.e. there were only a couple of links that absolutely had to have the event handler.</description>
		<content:encoded><![CDATA[<p>@Andrea &#8211; I specifically apply the onclick (nasty, but only used in desperate situations) on the links that should hook JS actions that I knew were required. i.e. there were only a couple of links that absolutely had to have the event handler.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mdmadph</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256541</link>
		<dc:creator>mdmadph</dc:creator>
		<pubDate>Thu, 24 Apr 2008 19:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256541</guid>
		<description>Why, just put all your scripts at the bottom, but have a big, opaque &lt; div &gt; covering the entire page with a &quot;loading&quot; gif in it.  Then, when your initial scripts are done, fade it out and show the HTML content.

I&#039;ve found this works particularly well for web applications, since users are most likely already used to having a loading screen while waiting for an application to load.  You can even get fancy and update the loading&quot;screen with relevant information, like a progress bar.</description>
		<content:encoded><![CDATA[<p>Why, just put all your scripts at the bottom, but have a big, opaque &lt; div &gt; covering the entire page with a &#8220;loading&#8221; gif in it.  Then, when your initial scripts are done, fade it out and show the HTML content.</p>
<p>I&#8217;ve found this works particularly well for web applications, since users are most likely already used to having a loading screen while waiting for an application to load.  You can even get fancy and update the loading&#8221;screen with relevant information, like a progress bar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Meiert</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256510</link>
		<dc:creator>Jens Meiert</dc:creator>
		<pubDate>Thu, 24 Apr 2008 18:16:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256510</guid>
		<description>The only important reason to put scripts at the end of a file appears to be missing, namely to avoid â€œinvalidâ€ numbers (statistics). IIRC, putting analytics scripts at the end â€œensuresâ€ that the page is really loaded and that it can be considered a valid page view (otherwise, users cancelling or going back could be counted w/o actually seeing the entire document).</description>
		<content:encoded><![CDATA[<p>The only important reason to put scripts at the end of a file appears to be missing, namely to avoid â€œinvalidâ€ numbers (statistics). IIRC, putting analytics scripts at the end â€œensuresâ€ that the page is really loaded and that it can be considered a valid page view (otherwise, users cancelling or going back could be counted w/o actually seeing the entire document).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AndrÃ© LuÃ­s</title>
		<link>http://robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256380</link>
		<dc:creator>AndrÃ© LuÃ­s</dc:creator>
		<pubDate>Thu, 24 Apr 2008 15:08:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.robertnyman.com/2008/04/23/where-to-include-javascript-files-in-a-document/#comment-256380</guid>
		<description>&quot;Getting head&quot;!!!! baaaaaahahahahahhahahaha LMFAO!!!!

You, Rob, are definitely THE Rockstar!!! :D</description>
		<content:encoded><![CDATA[<p>&#8220;Getting head&#8221;!!!! baaaaaahahahahahhahahaha LMFAO!!!!</p>
<p>You, Rob, are definitely THE Rockstar!!! <img src='http://robertnyman.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
