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

Code: Hello world optimized step 1

Chapter 8 - Ajax Optimization

If we crunch down the script portion of the page, as shown next, we reduce the overall file size to 1,043 bytes, which is more than a 30% savings:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<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){"GET","sayhello.php");
x.onreadystatechange=function( ){if(x.readyState==4&&x.status==200)
getElementsByTagName("message")[0].firstChild.nodeValue};x.send( );}}
window.onload=function( ){d.getElementById("button1").onclick=s}
<form action="#">
<input type="button" value="Say it!" id="button1" />
<br /><br />
<div id="output"> </div>
Copyright © 2002-2018 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