Call (877) SITE-OPT (748-3678)

Code: Hello world optimized step 2

Chapter 8 - Ajax Optimization

Applying many of the ideas in Chapter 6 for markup optimization, we can reduce this further to 1,023 bytes, which makes it nearly 32% smaller than the original:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/
xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Ajax
Hello World</title><script type="text/javascript">d=document;M="Msxml2.
XMLHTTP";function c( ){try{return new XMLHttpRequest(
)}catch(e){}try{A=ActiveXObject;return new A(M+".6.0")}catch(e){}try {return new
A(M+".3.0")}catch(e){}try {return new A(M)}catch(e){}try {return new A("Microsoft.
XMLHTTP")}catch(e){}}function s( ){var x=c( );if(x){x.open("GET","sayhello.php");x.
onreadystatechange=function( ){if(x.readyState==4&&x.status==200)d.
getElementById("output").innerHTML=x.responseXML.getElementsByTagName("message")[0].
firstChild.nodeValue};x.send( );}}window.onload=function( ){d.
getElementById("button1").onclick=s}</script></head><body><form action="#"><input
type="button" value="Say it!" id="button1" /></form><br /><br /><div id="output">
 </div></body></html>
Copyright © 2002-2017 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In