<?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: javascript to the rescue?</title>
	<atom:link href="http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/feed/" rel="self" type="application/rss+xml" />
	<link>http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/</link>
	<description>Enhancing your Ubuntu experience!</description>
	<lastBuildDate>Thu, 02 Feb 2012 10:29:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ben</title>
		<link>http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/#comment-29</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Wed, 14 Nov 2007 13:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=37#comment-29</guid>
		<description>Try this:



&lt;!--
function setimage()
{
var thedate=new Date();                                  //get the date from the computer
var nday=thedate.getDate();                               //extract the day (0-6) from the date
var str=&#039;image&#039;+nday+&#039;.jpg&#039;;                             //create the image file name: &#039;imageX.jpg&#039;, where X is the day
document.images[&#039;image&#039;].src=str;                        //assign the image file name
}



You will also need to add the following to the body:
onLoad=&quot;setimage()&quot;

This allows for a daily changing of your banner or image.  All you need to store all your images in the same folder as your page.  You also need to name each image as follows: image1, image2, image3 etc.</description>
		<content:encoded><![CDATA[<p>Try this:</p>
<p>&lt;!&#8211;<br />
function setimage()<br />
{<br />
var thedate=new Date();                                  //get the date from the computer<br />
var nday=thedate.getDate();                               //extract the day (0-6) from the date<br />
var str=&#8217;image&#8217;+nday+&#8217;.jpg&#8217;;                             //create the image file name: &#8216;imageX.jpg&#8217;, where X is the day<br />
document.images['image'].src=str;                        //assign the image file name<br />
}</p>
<p>You will also need to add the following to the body:<br />
onLoad=&#8221;setimage()&#8221;</p>
<p>This allows for a daily changing of your banner or image.  All you need to store all your images in the same folder as your page.  You also need to name each image as follows: image1, image2, image3 etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/#comment-28</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Fri, 28 Apr 2006 13:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=37#comment-28</guid>
		<description>Using JavaScript is an option, even though it may not be the best.  However, it is really easy setting up.

Just setup an array with each element in the array holding the image location on the server.  Then setup a timer to rotate through the elements every 3 seconds, or whatever.  Finally, put your newly created JavaScript function in the HTML image tag and your set.

As far as bandwidth, however, constantly pulling images may infact increase your bandwidth in the long term, then a single 800KB image that is only called once.  I guess you would have to decide what is more important.  Your bandwidth, or the load time of the user.</description>
		<content:encoded><![CDATA[<p>Using JavaScript is an option, even though it may not be the best.  However, it is really easy setting up.</p>
<p>Just setup an array with each element in the array holding the image location on the server.  Then setup a timer to rotate through the elements every 3 seconds, or whatever.  Finally, put your newly created JavaScript function in the HTML image tag and your set.</p>
<p>As far as bandwidth, however, constantly pulling images may infact increase your bandwidth in the long term, then a single 800KB image that is only called once.  I guess you would have to decide what is more important.  Your bandwidth, or the load time of the user.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Brantley</title>
		<link>http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/#comment-27</link>
		<dc:creator>Kyle Brantley</dc:creator>
		<pubDate>Fri, 28 Apr 2006 00:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=37#comment-27</guid>
		<description>Sadly, if you&#039;re looking at 800kB in pictures like that, the solution is simple: don&#039;t.

That said, for things like this, I&#039;ve seen flash (sorry) do simply *amazing* things that I couldn&#039;t dream of doing otherwise. This is mostly in terms of file size and animation. I don&#039;t know the specifics, but for something that&#039;s going to be 800kB in raw pictures, flash WILL save you a LOT of bandwidth (if you do it right). Several hundred kB (likely well over 650-700), unless you&#039;ve got things like motion video going on.

Universal compat. with flash? Good question. The site is obviously biased a bit, but they can only fake their figures so much: http://www.macromedia.com/software/player_census/flashplayer/

(I can&#039;t believe I just recommended flash for something... though in all honesty, I wouldn&#039;t be doing stuff like that in the first place, so whatever :))</description>
		<content:encoded><![CDATA[<p>Sadly, if you&#8217;re looking at 800kB in pictures like that, the solution is simple: don&#8217;t.</p>
<p>That said, for things like this, I&#8217;ve seen flash (sorry) do simply *amazing* things that I couldn&#8217;t dream of doing otherwise. This is mostly in terms of file size and animation. I don&#8217;t know the specifics, but for something that&#8217;s going to be 800kB in raw pictures, flash WILL save you a LOT of bandwidth (if you do it right). Several hundred kB (likely well over 650-700), unless you&#8217;ve got things like motion video going on.</p>
<p>Universal compat. with flash? Good question. The site is obviously biased a bit, but they can only fake their figures so much: <a href="http://www.macromedia.com/software/player_census/flashplayer/" rel="nofollow">http://www.macromedia.com/software/player_census/flashplayer/</a></p>
<p>(I can&#8217;t believe I just recommended flash for something&#8230; though in all honesty, I wouldn&#8217;t be doing stuff like that in the first place, so whatever <img src='http://ubuntu-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Fugal</title>
		<link>http://ubuntu-tutorials.com/2006/04/27/javascript-to-the-rescue/#comment-26</link>
		<dc:creator>Jacob Fugal</dc:creator>
		<pubDate>Thu, 27 Apr 2006 21:16:34 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=37#comment-26</guid>
		<description>Regarding whether the javascript option really is more bandwidth-friendly:

Whichever solution you use you will need to have data representing each of the images used. In the case of an animated gif those are all smashed into one file. I&#039;m not sure exactly how a Flash movie is encoded -- ie. whether the images would be stored individually or as frame differences -- but either way, unless the images have some coherency, you&#039;ll be storing the full data for all images in the Flash movie as well. Finally, for the javascript option you also need to have the data for all images, but they can be stored in separate files.

The only difference in total bandwidth you&#039;ll get between solutions will be due to the overhead of each. How much overhead does the movie timing in flash add? How much overhead does the animated gif format add? How much overhead does the javascript have?

Seeing as that you can build the requisite javascript in about 10-15 lines of code, I&#039;m guessing the size of the javascript overhead is on the order of ~100 bytes. I doubt either of the solutions will have an overhead significantly (order of magnitude) smaller. And compared to the size of the images, the javascript overhead is definitely negligible.

Additionally, with a javascript solution -- as I mentioned above -- you have the bonus of being able to transfer the images separately. As a result, you can display the first image as soon as it&#039;s arrived; with flash or an animated gif you need to wait for the whole payload to arrive before it can begin playing. And if the second image takes longer to come over, you can just delay replacing the image until the second one gets there.

For this situation[1], I&#039;d definitely choose the javascript option. It even degrades gracefully -- if the client doesn&#039;t have javascript enabled, they still see the first image, just no rotation.

Jacob Fugal

[1] Obvious disclaimer: Other situations may call for other solutions. I&#039;d hate to have to write a Home Star Runner movie using image replacement in javascript. :)</description>
		<content:encoded><![CDATA[<p>Regarding whether the javascript option really is more bandwidth-friendly:</p>
<p>Whichever solution you use you will need to have data representing each of the images used. In the case of an animated gif those are all smashed into one file. I&#8217;m not sure exactly how a Flash movie is encoded &#8212; ie. whether the images would be stored individually or as frame differences &#8212; but either way, unless the images have some coherency, you&#8217;ll be storing the full data for all images in the Flash movie as well. Finally, for the javascript option you also need to have the data for all images, but they can be stored in separate files.</p>
<p>The only difference in total bandwidth you&#8217;ll get between solutions will be due to the overhead of each. How much overhead does the movie timing in flash add? How much overhead does the animated gif format add? How much overhead does the javascript have?</p>
<p>Seeing as that you can build the requisite javascript in about 10-15 lines of code, I&#8217;m guessing the size of the javascript overhead is on the order of ~100 bytes. I doubt either of the solutions will have an overhead significantly (order of magnitude) smaller. And compared to the size of the images, the javascript overhead is definitely negligible.</p>
<p>Additionally, with a javascript solution &#8212; as I mentioned above &#8212; you have the bonus of being able to transfer the images separately. As a result, you can display the first image as soon as it&#8217;s arrived; with flash or an animated gif you need to wait for the whole payload to arrive before it can begin playing. And if the second image takes longer to come over, you can just delay replacing the image until the second one gets there.</p>
<p>For this situation[1], I&#8217;d definitely choose the javascript option. It even degrades gracefully &#8212; if the client doesn&#8217;t have javascript enabled, they still see the first image, just no rotation.</p>
<p>Jacob Fugal</p>
<p>[1] Obvious disclaimer: Other situations may call for other solutions. I&#8217;d hate to have to write a Home Star Runner movie using image replacement in javascript. <img src='http://ubuntu-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic (User agent is rejected)
Database Caching 2/6 queries in 0.004 seconds using disk: basic
Object Caching 251/252 objects using disk: basic

Served from: ubuntu-tutorials.com @ 2012-02-09 16:58:42 -->
