<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Kristoffer's tidbits : Website Performance</title><link>http://blogs.msdn.com/kristoffer/archive/tags/Website+Performance/default.aspx</link><description>Tags: Website Performance</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Loading website images in parallel</title><link>http://blogs.msdn.com/kristoffer/archive/2006/12/27/loading-website-images-in-parallel.aspx</link><pubDate>Wed, 27 Dec 2006 20:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1369810</guid><dc:creator>Kristoffer</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/kristoffer/comments/1369810.aspx</comments><wfw:commentRss>http://blogs.msdn.com/kristoffer/commentrss.aspx?PostID=1369810</wfw:commentRss><description>&lt;p&gt;By default web browsers will only open 2 simultaneous connections to a named website to be a good client. If you're loading several images this means you may hamstring your bandwidth usage and make your website load slower.&lt;/p&gt; &lt;p&gt;Take the following HTML source as our base, off a site hosted at www.example.com:&lt;/p&gt; &lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image1.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image2.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image3.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image4.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image5.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image6.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;!--EndFragment--&gt; &lt;div style="border: 1px inset black; margin-top: 5px; padding-bottom: 10px; margin-left: 30px; width: 500px; background-color: rgb(192, 192, 192);"&gt;Network traffic for downloading 6 images over 2 connections  &lt;div style="padding-right: 10px; padding-left: 10px; padding-top: 10px;"&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;www&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image1.png&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image3.png&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image5.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;www&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image2.png&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image4.png&lt;/td&gt; &lt;td style="margin: 2px; width: 150px; background-color: rgb(142, 196, 207);"&gt;Image6.png&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;By not allowing more than 2 images to be downloaded at once the total page load time takes longer than is necessary. Since we own the host in question we know we can safely allow more than 2 images to be downloaded at once so we create two DNS aliases, img1.example.com and img2.example.com that both point to www.example.com. We now modify our HTML source to make use of these two new hosts:&lt;/p&gt; &lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image1.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image2.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://img1.example.com/Image3.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://img1.example.com/Image4.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://img2.example.com/Image5.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://img2.example.com/Image6.png"&lt;/span&gt; &lt;span style="color: red;"&gt;width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: red;"&gt;height&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Web browsers will now open 2 connections per named host (www.example.com, img1.example.com, and img2.example.com) for a total of 6 concurrent connections.&lt;/p&gt; &lt;div style="border: 1px inset black; margin-top: 5px; padding-bottom: 10px; margin-left: 30px; width: 500px; background-color: rgb(192, 192, 192);"&gt;Network traffic for downloading 6 images over 6 connections  &lt;div style="padding-right: 10px; padding-left: 10px; padding-top: 10px;"&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;www&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image1.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;www&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image2.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;img1&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image3.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;img1&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image4.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;img2&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image5.png&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td style="font-weight: bold; width: 100px;"&gt;img2&lt;/td&gt; &lt;td style="margin: 2px; width: 180px; background-color: rgb(142, 196, 207);"&gt;Image6.png&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Downloading all of them at the same time decreases the amount of bandwidth available for any individual image but will maximize the overall bandwidth usage leading to faster load times.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1369810" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/kristoffer/archive/tags/Website+Performance/default.aspx">Website Performance</category></item><item><title>Loading Javascript files in parallel</title><link>http://blogs.msdn.com/kristoffer/archive/2006/12/22/loading-javascript-files-in-parallel.aspx</link><pubDate>Fri, 22 Dec 2006 23:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1349461</guid><dc:creator>Kristoffer</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/kristoffer/comments/1349461.aspx</comments><wfw:commentRss>http://blogs.msdn.com/kristoffer/commentrss.aspx?PostID=1349461</wfw:commentRss><description>&lt;p&gt;You've got your website all set up but are experiencing slow load times for some customers, especially on slower connections. One possible cause is inefficient network usage because of serialized loading of external Javascript files.&lt;/p&gt; &lt;h3&gt;Static links in &amp;lt;head&amp;gt;&lt;/h3&gt; &lt;p&gt;If you include script files in the HEAD element both IE and Firefox will download the scripts serially, waiting for each one to finish downloading before proceeding with the next one. Take the following HTML snippet that loads two external javascripts:  &lt;/p&gt;&lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Script1.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="Script2.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;!--EndFragment--&gt;&lt;/div&gt; &lt;div style="border: 1px inset black; margin-top: 5px; padding-bottom: 10px; margin-left: 30px; width: 500px; background-color: rgb(192, 192, 192);"&gt;Network traffic for loading scripts in &amp;lt;head&amp;gt; tag  &lt;div style="padding-right: 10px; padding-left: 10px; padding-top: 10px;"&gt; &lt;div style="padding: 1px; width: 200px; background-color: red;"&gt;Script1.js&lt;/div&gt; &lt;div style="padding: 1px; margin-top: 2px; margin-left: 205px; width: 200px; background-color: green;"&gt;Script2.js&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;In this common scenario a large amount of network bandwidth can potentially go unused.&lt;/p&gt; &lt;h3&gt;Loading the scripts in parallel&lt;/h3&gt;You have two options for loading scripts in parallel:  &lt;ul&gt; &lt;li&gt;Attach them as elements dynamically  &lt;/li&gt;&lt;li&gt;Use document.write to attach them &lt;/li&gt;&lt;/ul&gt;Both of these options will produce the same network traffic with the difference being in how the scripts are executed on the client. By loading the scripts in parallel we can cut down initial page load time drastically. The time for Script1.js to finish downloading will probably go up slightly over serial loading (since more of the connection is used) but the overall download time should decrease.  &lt;div style="border: 1px inset black; margin-top: 5px; padding-bottom: 10px; margin-left: 30px; width: 500px; background-color: rgb(192, 192, 192);"&gt;Network traffic for&amp;nbsp;loading scripts in parallel&amp;nbsp;  &lt;div style="padding-right: 10px; padding-left: 10px; padding-top: 10px;"&gt; &lt;div style="padding: 1px; width: 230px; background-color: red;"&gt;Script1.js&lt;/div&gt; &lt;div style="padding: 1px; margin-top: 2px; width: 230px; background-color: green;"&gt;Script2.js&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;h4&gt;Attaching scripts as elements&amp;nbsp;dynamically&lt;/h4&gt; &lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;function&lt;/span&gt; AttachScript(src)&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;var&lt;/span&gt; script = document.createElement(&lt;span style="color: maroon;"&gt;"SCRIPT"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; script.type = &lt;span style="color: maroon;"&gt;"text/javascript"&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementsByTagName(&lt;span style="color: maroon;"&gt;"body"&lt;/span&gt;)[0].appendChild(script);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; script.src = src;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AttachScript(&lt;span style="color: maroon;"&gt;"Script1.js"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AttachScript(&lt;span style="color: maroon;"&gt;"Script2.js"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;In this scenario IE and Firefox will download both scripts &lt;b&gt;but&lt;/b&gt; Internet Explorer will also execute them in the order they finish downloading in whereas Firefox downloads them asynchronously but still executes them in the order they are attached in the DOM. &lt;/p&gt; &lt;p&gt;In Internet Explorer this means your scripts cannot have dependancies on one another as the execution order will vary depending on network traffic, caches, etc.&lt;/p&gt; &lt;p&gt;In Firefox&amp;nbsp;you can mostly get away with keeping dependancies on Script1 from Script2 with the caveat that&amp;nbsp;if the user presses stop after Script2 has finished downloading but Script1 has not, Firefox will execute Script2 and abort downloading Script1. Ensure that Script2 can properly handle Script1 failing to load.&lt;/p&gt; &lt;h3&gt;Attaching scripts via document.write&lt;/h3&gt; &lt;div style="background: white none repeat scroll 0% 50%; font-size: 10pt; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: black; font-family: courier new;"&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp; document.writeln(&lt;span style="color: maroon;"&gt;"&amp;lt;script type='text/javascript' src='Script1.js'&amp;gt;&amp;lt;"&lt;/span&gt; + &lt;span style="color: maroon;"&gt;"/script&amp;gt;"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&amp;nbsp; document.writeln(&lt;span style="color: maroon;"&gt;"&amp;lt;script type='text/javascript' src='Script2.js'&amp;gt;&amp;lt;"&lt;/span&gt; + &lt;span style="color: maroon;"&gt;"/script&amp;gt;"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;!--EndFragment--&gt; &lt;p&gt;Using document.write produces the same effect in both Internet Explorer and Firefox: the scripts are downloaded in parallel but executed in the order they're written to the page. The same caveat above about the user stopping the page after Script2 has finished downloading before Script1 has applies.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;This technique can be used to download more than two files at the same time as long as more than 1 hostname is used. IE will only open 2 HTTP connections to a named server in order to be a good client (Firefox will open 4) but you can easily work around this by creating additional domain names like scripts1.example.com, scripts2.example.com etc that point to the same host. At some point you will see diminishing returns and possibly even slowdowns from trying to download too many files at once so don't go too crazy with parallelizing.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;br&gt;Edit: Noted that Firefox will open 4 connections per named host by default.&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1349461" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/kristoffer/archive/tags/Website+Performance/default.aspx">Website Performance</category></item></channel></rss>