<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7746785397689385135</id><updated>2011-11-27T17:41:35.404-08:00</updated><category term='php5'/><category term='web development'/><category term='oop'/><category term='HTML5'/><category term='class'/><title type='text'>AmitTechSol.com</title><subtitle type='html'>AmitTechSol.com, web design india, opensource customization, PHP, MySql, Ajax, DHTML, Html, CSS, JavaScript, Java, GWT, Oracle, Hibernate, Jsp, Servlet, Mambo, Joomla, Typo3 CMS, Drupal CMS, X-Cart, OsCommerce, DotNetNuke, PHPNuke, PHPBB, Zen Cart, WordPress website development company, web design india, website designing, website development company, website development, website design and development, web design, outsource web site design india, web hosting india</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://advancedmicrodevicesorg.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-1122026091320227865</id><published>2010-04-20T02:18:00.000-07:00</published><updated>2010-04-30T22:30:50.516-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web development'/><category scheme='http://www.blogger.com/atom/ns#' term='class'/><category scheme='http://www.blogger.com/atom/ns#' term='php5'/><category scheme='http://www.blogger.com/atom/ns#' term='oop'/><title type='text'>Getting Started with OOP &amp; PHP5</title><content type='html'>Since the introduction of PHP 5 in 2004, PHP has had an object model  worthy of that description and became a truly modern language for use on  the web.  Earlier PHP scripts would have been of the kind where, to  quote from Alice's Adventures, you would `"Begin at the beginning, and go  on till you come to the end: then stop."&lt;br /&gt;Nowadays that very procedural approach is less common in PHP, so this  article takes a look at some of the basic object oriented features  available in the language and shows some examples of using them with  code examples.&lt;br /&gt;&lt;br /&gt;Using OOP (Object Orientated Programming) enables us to architect our  systems much more clearly, and to make them more manageable and more  maintainable.  This technique also allows us to separate form from  function to create clean, navigable codebases with plenty of  opportunities to reuse code, apply design patterns and bring in concepts  from other brances of computer science.&lt;br /&gt;&lt;h3&gt;Objects vs Classes&lt;/h3&gt;While the terms "object" and "class" are often used almost  interchangeably in the world of software, there is a definite conceptual  difference between the two.  A class is the blueprint or recipe; it  describes what the object should be, have and do.  So a class might look  like this:&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;/div&gt;&lt;pre&gt;&lt;code&gt;class Elephpant {&lt;br /&gt;    public $colour;&lt;br /&gt;&lt;br /&gt;    public function dance() {&lt;br /&gt;        echo "elephpant dances!\n";&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;elephpant.php&lt;/b&gt;&lt;br /&gt;An object, on the other hand, is an actual instantiation of the class  – its an actual thing, with values and behaviours.  In the example  below, $ele is the object:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('elephpant.php');&lt;br /&gt;&lt;br /&gt;$ele = new Elephpant();&lt;/code&gt;&lt;/pre&gt;We can inspect $ele to make sure that it is, in fact, an object of  the class Elephpant, using the &lt;tt&gt;&lt;a href="http://php.net/manual/en/function.print-r.php"&gt;print_r&lt;/a&gt;&lt;/tt&gt;  command.  Adding this to our code sample as shown, we see the output  below:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('elephpant.php');&lt;br /&gt;&lt;br /&gt;$ele = new Elephpant();&lt;br /&gt;print_r($ele);&lt;br /&gt;&lt;br /&gt;Elephpant Object&lt;br /&gt;(&lt;br /&gt;    [colour] =&amp;gt;&lt;br /&gt;)&lt;/code&gt;&lt;/pre&gt;This output shows an object, of type Elephpant, and with a single  empty property named "colour".  For more information about the objects  exact properties and their values, you can also use &lt;tt&gt;&lt;a href="http://php.net/manual/en/function.var-dump.php"&gt;var_dump&lt;/a&gt;&lt;/tt&gt;,  which gives a more detailed output showing in detail the datatypes of  each property.  This is particularly useful for spotting empty strings,  nulls and false.&lt;br /&gt;&lt;h3&gt;Using Objects, Their Properties and Methods&lt;/h3&gt;Our class, Elephpant, has a property and a method (OO-speak for  "function") already defined inside it, so how can we interact with  these?  Let's start by setting the colour property; we use the object  operator which is a hyphen followed by a greater than sign.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('elephpant.php');&lt;br /&gt;&lt;br /&gt;$ele = new Elephpant();&lt;br /&gt;&lt;br /&gt;// set the colour property&lt;br /&gt;$ele-&amp;gt;colour = "blue";&lt;br /&gt;&lt;br /&gt;// now use that property&lt;br /&gt;echo "The elephpant is " . $ele-&amp;gt;colour;&lt;/code&gt;&lt;/pre&gt;The output of this script reads "The elephpant is blue".  The  property will remain set on the object until the object is destroyed, or  the property overwritten or unset.  Objects are a great way of keeping  things together that belong together, for example information about an  elephpant!&lt;br /&gt;Similarly we can call the method using the same operator – the  brackets after the call let PHP know its a method rather than a  property, and if we had parameters to pass in they'd go between the  brackets.  Something like this:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('elephpant.php');&lt;br /&gt;&lt;br /&gt;$ele = new Elephpant();&lt;br /&gt;&lt;br /&gt;// call the dance method&lt;br /&gt;$ele-&amp;gt;dance();&lt;/code&gt;&lt;/pre&gt;Look back at the class declaration for Elephpant and you'll see the  dance method actually echoes from within it.  Indeed when we run the  code example here, we see "elephpant dances!" as our output.  It is a  very trivial example but I hope it does show how to call methods against  our objects.  An alternative approach (and probably a better one within  an actual application) would be to create the string and use it as the  return value for the function.  Then the calling code can take the  string and echo it, or do whatever else it needs to, in a more flexible  way.&lt;br /&gt;&lt;h3&gt;Inheritance&lt;/h3&gt;Now we know how to create and interact with objects, let's step  things up a bit and look at how we can create objects which are similar  in some ways and different in others, using inheritance.  If you are  accustomed to OOP from any other programming languages then this will  seem very familiar to you, so here is a quick look at how this can be  done in PHP. We already have our Elephpant class declared, so let's add a  Penguin class as well.  They will both inherit from the parent class  Animal, which looks like this:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;class Animal{&lt;br /&gt;&lt;br /&gt;    public $type = "animal";&lt;br /&gt;&lt;br /&gt;    public function dance() {&lt;br /&gt;        echo $this-&amp;gt;type . " dances!\n";&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;animal.php&lt;/b&gt;&lt;br /&gt;The animal has a "type" property, and a dance() method.  It uses the  type property in the dance() method to create the output, using $this to  refer to the current object.  In PHP, $this is a special keyword which  refers to the current object from within its own class.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;/div&gt;Now we can create a Penguin class that inherits from this general  Animal class, by using the extends keyword to denote its parent:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;class Penguin extends Animal {&lt;br /&gt;    public $type = "penguin";&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;penguin.php&lt;/b&gt;&lt;br /&gt;The penguin class would inherit the type property set to "animal" if  we didn't override it by setting the property again in this class.   However even without declaring a dance() method, the penguin can dance!&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('animal.php');&lt;br /&gt;include('penguin.php');&lt;br /&gt;&lt;br /&gt;$tux = new Penguin();&lt;br /&gt;&lt;br /&gt;// make tux dance&lt;br /&gt;$tux-&amp;gt;dance();&lt;/code&gt;&lt;/pre&gt;The above example gives the output "penguin dances!" – using the  dance() method from the Animal class, which is available because the  Penguin class extends it, and the type property set separately in the  Penguin class itself.&lt;br /&gt;&lt;h3&gt;Access Modifiers&lt;/h3&gt;Take a look at the previous example.  The type is set in the class,  but we could easily set it from our main code if we wanted to.  Imagine  if we put $tux-&amp;gt;type = "giraffe" before we asked him to dance!   Sometimes this is the desired behaviour, and sometimes it isn't.  To  allow us to control whether properties can be changed outside a class,  PHP gives us access modifiers.  An example of these are the "public"  keywords you see in the classes shown above.  To prevent the type  property being edited from outside the class, we can declare the Penguin  type to be private, so the class now looks like this:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;class Penguin extends Animal {&lt;br /&gt;    private $type = "penguin";&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;private_penguin.php&lt;/b&gt;&lt;br /&gt;The following code listing shows us trying to set the now-private  type property, and is followed by the resulting output.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;include('animal.php');&lt;br /&gt;include('private_penguin.php');&lt;br /&gt;&lt;br /&gt;$tux = new Penguin();&lt;br /&gt;&lt;br /&gt;// change the type&lt;br /&gt;$tux-&amp;gt;type = "linux penguin";&lt;br /&gt;// make tux dance&lt;br /&gt;$tux-&amp;gt;dance();&lt;br /&gt;&lt;br /&gt;Fatal error: Access level to Penguin::$type must be public (as in class Animal) in /home/lorna/.../OOP/private_penguin.php on line 5&lt;/code&gt;&lt;/pre&gt;The resulting message feeds back to the user that the type property  can't be modified, and even includes the detail that the property was  public in the parent class.  Access modifiers are pretty powerful, we  should look at them in more detail.&lt;br /&gt;Access modifiers can be applied to properties and to methods and to  properties.  The options are public, private and protected.  In PHP4,  these weren't available and everything is public.  As a result, and to  maintain backwards compatibility, if an access modifier isn't specified  then the property or method defaults to being public.  This isn't  recommended practice however, and it is best to be explicit about which  is intended.&lt;br /&gt;&lt;b&gt;Public:&lt;/b&gt; The public access modifier means that  properties and methods can be accessed from anywhere, within the scope  of the object itself, and also from outside code operating on an object.&lt;br /&gt;&lt;b&gt;Private: &lt;/b&gt;The method or property is only available  from within the scope of this specific class.  Before using this option,  read on to find out about the "protected" access modifier.&lt;br /&gt;&lt;b&gt;Protected: &lt;/b&gt;The method or property is available from  within this class, and from within any classes with extend or implement  this class.  This is ideal where you don't want external code to change  the class, but you do want to be able to extend the class later and take  advantage of this property or method.  Protected is more flexible than  private and almost always the better choice.&lt;br /&gt;Using these access modifiers we can control where our class methods  and properties can be accessed from.  We looked at an example of  properties and this works in the same way for method calls – they cannot  be accessed from outside of the class definition unless they are  declared to be public.  It can be very useful indeed to declare methods  as protected, where they are internal helper methods used by other class  methods but not intended to be accessed directly.  In PHP4 there was no  support for this and so the internal methods were sometimes named with  an underscore to hint that this was their intended use – it is still  possible to see this naming convention in use today, although it is not  needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-1122026091320227865?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/1122026091320227865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/1122026091320227865'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/04/getting-started-with-oop-php5.html' title='Getting Started with OOP &amp;amp; PHP5'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-6623269942357277271</id><published>2010-04-05T02:16:00.000-07:00</published><updated>2010-04-06T02:21:57.706-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><title type='text'>HTML5 – New Old Semantics</title><content type='html'>&lt;p&gt;We are sure that you’ll agree that HTML is one of the best web inventions of all times. The hyper text markup language is actually the cornerstone of modern web that appears to be a unique and self-sufficient phenomenon.&lt;/p&gt;&lt;p&gt;When HTML5 was being developed its developers have faced the few important issues that were to be solved with the help of HTML5. And one of these problems was creating a really explicit and extensible semantics. Now the tricky part is that the old versions of HTML were also being designed with the versatility in mind – with loads of various tags that were considered absolutely essential but have eventually proved themselves to be totally useless. The approach in the HTML5 has been changed according to the needs of today’s Internet.&lt;/p&gt;&lt;h3&gt;HTML5 New Tags&lt;/h3&gt;&lt;p&gt;The task that had to be accomplished by the developers was to create the richer and meaningful semantics for HTML5 version – plus the fact that new solution was supposed to be flexible, strongly efficient and of course to correspond to all modern web standards. Now here comes the list of the new tags that will available in HTML5.&lt;/p&gt;&lt;ul&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;article&amp;gt;&lt;/strong&gt; tag defines an article&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;aside&amp;gt;&lt;/strong&gt; tag defines content aside from the page content&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;audio&amp;gt;&lt;/strong&gt; tag defines sound content&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;canvas&amp;gt;&lt;/strong&gt; tag defines graphics&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;command&amp;gt;&lt;/strong&gt; tag defines a command button&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;datalist&amp;gt;&lt;/strong&gt; tag defines a dropdown list&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;details&amp;gt;&lt;/strong&gt; tag defines details of an element&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;dialog&amp;gt;&lt;/strong&gt; tag defines a dialog (conversation)&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;embed&amp;gt;&lt;/strong&gt; tag defines external interactive content or plugin&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;figure&amp;gt;&lt;/strong&gt; tag defines a group of media content, and their caption&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;footer&amp;gt;&lt;/strong&gt; tag defines a footer for a section or page&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;header&amp;gt;&lt;/strong&gt; tag defines a header for a section or page&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;hgroup&amp;gt;&lt;/strong&gt; tag defines information about a section in a document&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;keygen&amp;gt;&lt;/strong&gt; tag defines a generated key in a form&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;mark&amp;gt;&lt;/strong&gt; tag defines marked text&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;meter&amp;gt;&lt;/strong&gt; tag defines measurement within a predefined range&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;nav&amp;gt;&lt;/strong&gt; tag defines navigation links&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;output&amp;gt;&lt;/strong&gt; tag defines some types of output&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;progress&amp;gt;&lt;/strong&gt; tag defines progress of a task of any kind&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;rp&amp;gt;&lt;/strong&gt; tag is used in ruby annotations to define what to show browsers that do not support the ruby element.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;rt&amp;gt;&lt;/strong&gt; tag defines explanation to ruby annotations.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;ruby&amp;gt;&lt;/strong&gt; tag defines ruby annotations.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;section&amp;gt;&lt;/strong&gt; tag defines a section&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;source&amp;gt;&lt;/strong&gt; tag defines media resources&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;time&amp;gt; &lt;/strong&gt;tag defines a date/time&lt;/li&gt;&lt;li&gt; &lt;strong&gt;&amp;lt;video&amp;gt;&lt;/strong&gt; tag defines a video&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-6623269942357277271?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/6623269942357277271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/6623269942357277271'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/04/html5-new-old-semantics.html' title='HTML5 – New Old Semantics'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-8219706246286000619</id><published>2010-04-03T11:44:00.000-07:00</published><updated>2010-04-03T11:44:59.203-07:00</updated><title type='text'>Using OOP in PHP: Practical Example</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;Object Oriented design is particularly useful where you have data  objects that relate to one another – so it is very common for example to  have OOP used to deal with data.  PHP 5 has the &lt;a href="http://php.net/manual/en/book.pdo.php"&gt;PDO (PHP Data Object)&lt;/a&gt;  classes which are a great way to talk to a backend database, either  mysql or any other kind of database, and using the object oriented  interface offered by this extension ties in well with the usage I have  shown here.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;A common mistake for those coming to OO for the first time is to  declare methods inside a class but then instantiate a single copy of  that and pass in data such as the ID of the data to each method.  Here’s  an example of a user class that does this:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;class User {&lt;br /&gt;    /**&lt;br /&gt;     * getDisplayName&lt;br /&gt;     *&lt;br /&gt;     * @param int $user_id the user_id of the user in the database table&lt;br /&gt;     * @access public&lt;br /&gt;     * @return string Display name of this user&lt;br /&gt;     */&lt;br /&gt;    public function getDisplayName($user_id) {&lt;br /&gt;        $sql = 'select display_name from users where user_id = '.$user_id;&lt;br /&gt;        $results = mysql_query($sql);&lt;br /&gt;        $row = mysql_fetch_array($results);&lt;br /&gt;        return $row['display_name'];&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * getFriends&lt;br /&gt;     *&lt;br /&gt;     * @param int $user_id the user_id of the user in the database table&lt;br /&gt;     * @access public&lt;br /&gt;     * @return array An array of friend_ids&lt;br /&gt;     */&lt;br /&gt;    public function getFriends($user_id) {&lt;br /&gt;        $sql = 'select friend_id from user_friends where user_id = '.$user_id;&lt;br /&gt;        $results = mysql_query($sql);&lt;br /&gt;        $friends = array();&lt;br /&gt;        while($row = mysql_fetch_array($results)) {&lt;br /&gt;            $friends[] = $row['friend_id'];&lt;br /&gt;        }&lt;br /&gt;        return $friends;&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;user.php&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;And some code that uses it:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;include('user.php');&lt;br /&gt;mysql_connect('localhost','root','');&lt;br /&gt;mysql_select_db('test');&lt;br /&gt;&lt;br /&gt;$user = new User();&lt;br /&gt;echo "User known as: " . $user-&amp;gt;getDisplayName(1) . "\n";&lt;br /&gt;&lt;br /&gt;$friends = $user-&amp;gt;getFriends(1);&lt;br /&gt;echo "Friends with: " . implode(', ',$friends) . "\n";&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;If you want to run this code yourself, then you can set up the  database tables using this script:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;CREATE TABLE `user_friends` (&lt;br /&gt;  `user_friend_id` int(11) NOT NULL AUTO_INCREMENT,&lt;br /&gt;  `user_id` int(11) NOT NULL,&lt;br /&gt;  `friend_id` int(11) NOT NULL,&lt;br /&gt;  PRIMARY KEY (`user_friend_id`)&lt;br /&gt;)&lt;br /&gt;INSERT INTO `user_friends` VALUES (1,1,3),(2,1,5);&lt;br /&gt;&lt;br /&gt;CREATE TABLE `users` (&lt;br /&gt;  `user_id` int(11) NOT NULL AUTO_INCREMENT,&lt;br /&gt;  `first_name` varchar(20) DEFAULT NULL,&lt;br /&gt;  `last_name` varchar(50) DEFAULT NULL,&lt;br /&gt;  `display_name` varchar(50) DEFAULT NULL,&lt;br /&gt;  PRIMARY KEY (`user_id`)&lt;br /&gt;)&lt;br /&gt;INSERT INTO `users` VALUES (1,'Lorna','Mitchell','lornajane');&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;user.sql&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;This is more like a function library than an actual object, and  although it works perfectly well and does have its applications, it can  be better to aim to take advantage of more object oriented features.  To  do this, a new object should be created for each item the system  handles, and if it has an ID and perhaps some other properties, these  should be set as part of the object.  Then rather than creating a single  user object and doing getFriends(42) on it, you’d have a user with ID  42 which did $user-&amp;gt;getFriends().&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;Here’s a follow up example with a class and how to use it, this will  give better performance and enable you to clearly see which data goes  with which object where there are multiple items on a page:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;class User {&lt;br /&gt;    /**&lt;br /&gt;     * getUserById&lt;br /&gt;     *&lt;br /&gt;     * @param int $user_id the id of the user row in the table&lt;br /&gt;     * @access public&lt;br /&gt;     * @return true if the user was found&lt;br /&gt;     */&lt;br /&gt;    public function getUserById($user_id) {&lt;br /&gt;        $sql = 'select first_name, last_name, display_name from users where user_id = ' . $user_id;&lt;br /&gt;        $results = mysql_query($sql);&lt;br /&gt;        $row = mysql_fetch_array($results);&lt;br /&gt;        $this-&amp;gt;user_id = $user_id;&lt;br /&gt;        $this-&amp;gt;first_name = $row['first_name'];&lt;br /&gt;        $this-&amp;gt;last_name = $row['last_name'];&lt;br /&gt;        $this-&amp;gt;display_name = $row['display_name'];&lt;br /&gt;&lt;br /&gt;        // in real life, there would be escaping and error handling and we'd only return true if we got data&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * getDisplayName&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     * @return string Display name of this user&lt;br /&gt;     */&lt;br /&gt;    public function getDisplayName() {&lt;br /&gt;        return $this-&amp;gt;display_name;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * getFriends&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     * @return array An array of friend_ids&lt;br /&gt;     */&lt;br /&gt;    public function getFriends() {&lt;br /&gt;        $sql = 'select friend_id from user_friends where user_id = '.$this-&amp;gt;user_id;&lt;br /&gt;        $results = mysql_query($sql);&lt;br /&gt;        $friends = array();&lt;br /&gt;        while($row = mysql_fetch_array($results)) {&lt;br /&gt;            $friends[] = $row['friend_id'];&lt;br /&gt;        }&lt;br /&gt;        return $friends;&lt;br /&gt;    }&lt;br /&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;user2.php&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;code&gt;include('user2.php');&lt;br /&gt;mysql_connect('localhost','root','');&lt;br /&gt;mysql_select_db('test');&lt;br /&gt;&lt;br /&gt;$user = new User();&lt;br /&gt;// populate the object&lt;br /&gt;$user-&amp;gt;getUserById(1);&lt;br /&gt;echo "User known as: " . $user-&amp;gt;getDisplayName() . "\n";&lt;br /&gt;&lt;br /&gt;$friends = $user-&amp;gt;getFriends();&lt;br /&gt;echo "Friends with: " . implode(', ',$friends) . "\n";&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;&lt;h3 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;In Summary&lt;/span&gt;&lt;/h3&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;This has been a very introductory look at some of the object oriented  features available in PHP, to get you started out with the basics of  working with OO code and also writing your own.  If this has helped you  take your first OOP steps, then let us know by leaving a comment and let  us know what you built!  In the next post there will be some more  in-depth content including using constructors, access modifiers and  working with the static keyword in PHP – taking your skills to the next  level.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-8219706246286000619?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/8219706246286000619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/8219706246286000619'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/04/using-oop-in-php-practical-example.html' title='Using OOP in PHP: Practical Example'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4414546624627978423</id><published>2010-03-27T12:14:00.000-07:00</published><updated>2010-03-27T12:14:25.913-07:00</updated><title type='text'>The Java serialization algorithm revealed</title><content type='html'>&lt;h2 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;What  is serialization?&lt;/h2&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;em&gt;Serialization&lt;/em&gt; is the process of saving an object's state to a  sequence of bytes; &lt;em&gt;deserialization&lt;/em&gt; is the process of  rebuilding those bytes into a live object. The Java Serialization API  provides a standard mechanism for developers to handle object  serialization. In this tip, you will see how to serialize an object, and  why serialization is sometimes necessary. You'll learn about the  serialization algorithm used in Java, and see an example that  illustrates the serialized format of an object. By the time you're done,  you should have a solid knowledge of how the serialization algorithm  works and what entities are serialized as part of the object at a low  level.&lt;/div&gt;&lt;h2 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Why is serialization required?&lt;/h2&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;In today's world, a typical enterprise application will have multiple  components and will be distributed across various systems and networks.  In Java, everything is represented as objects; if two Java components  want to communicate with each other, there needs be a mechanism to  exchange data. One way to achieve this is to define your own protocol  and transfer an object. This means that the receiving end must know the  protocol used by the sender to re-create the object, which would make it  very difficult to talk to third-party components. Hence, there needs to  be a generic and efficient protocol to transfer the object between  components. Serialization is defined for this purpose, and Java  components use this protocol to transfer objects.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Figure 1 shows a high-level view of client/server communication,  where an object is transferred from the client to the server through  serialization.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;How to serialize an object&lt;/h2&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;In order to serialize an object, you need to ensure that the class of  the object implements the &lt;code&gt;java.io.Serializable&lt;/code&gt; interface,  as shown in Listing 1.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 1. Implementing Serializable&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;class TestSerial implements Serializable {&lt;br /&gt; public byte version = 100;&lt;br /&gt; public byte count = 0;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;In Listing 1, the only thing you had to do differently from creating a  normal class is implement the &lt;code&gt;java.io.Serializable&lt;/code&gt;  interface. The &lt;code&gt;Serializable&lt;/code&gt; interface is a marker  interface; it declares no methods at all. It tells the serialization  mechanism that the class can be serialized.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Now that you have made the class eligible for serialization, the next  step is to actually serialize the object. That is done by calling the &lt;code&gt;writeObject()&lt;/code&gt;  method of the &lt;code&gt;java.io.ObjectOutputStream&lt;/code&gt; class, as shown  in Listing 2.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 2. Calling writeObject()&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;public static void main(String args[]) throws IOException {&lt;br /&gt; FileOutputStream fos = new FileOutputStream("temp.out");&lt;br /&gt; ObjectOutputStream oos = new ObjectOutputStream(fos);&lt;br /&gt; TestSerial ts = new TestSerial();&lt;br /&gt; oos.writeObject(ts);&lt;br /&gt; oos.flush();&lt;br /&gt; oos.close();&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 2 stores the state of the &lt;code&gt;TestSerial&lt;/code&gt; object in a  file called &lt;code&gt;temp.out&lt;/code&gt;.  &lt;code&gt;oos.writeObject(ts);&lt;/code&gt;  actually kicks off the serialization algorithm, which in turn writes the  object to &lt;code&gt;temp.out&lt;/code&gt;.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;To re-create the object from the persistent file, you would employ  the code in Listing 3.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 3. Recreating a serialized object&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;public static void main(String args[]) throws IOException {&lt;br /&gt; FileInputStream fis = new FileInputStream("temp.out");&lt;br /&gt; ObjectInputStream oin = new ObjectInputStream(fis);&lt;br /&gt; TestSerial ts = (TestSerial) oin.readObject();&lt;br /&gt; System.out.println("version="+ts.version);&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;In Listing 3, the object's restoration occurs with the &lt;code&gt;oin.readObject()&lt;/code&gt;  method call. This method call reads in the raw bytes that we previously  persisted and creates a live object that is an exact replica of the  original object graph. Because &lt;code&gt;readObject()&lt;/code&gt; can read any  serializable object, a cast to the correct type is required. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Executing this code will print &lt;code&gt;version=100&lt;/code&gt; on the  standard output.&lt;/div&gt;&lt;h2 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The serialized format of an object&lt;/h2&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;What does the serialized version of the object look like? Remember,  the sample code in the previous section saved the serialized version of  the &lt;code&gt;TestSerial&lt;/code&gt; object into the file &lt;code&gt;temp.out&lt;/code&gt;.  Listing 4 shows the contents of &lt;code&gt;temp.out&lt;/code&gt;,  displayed in  hexadecimal. (You need a hexadecimal editor to see the output in  hexadecimal format.)&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 4. Hexadecimal form of TestSerial&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;AC ED 00 05 73 72 00 0A 53 65 72 69 61 6C 54 65&lt;br /&gt;73 74 A0 0C 34 00 FE B1 DD F9 02 00 02 42 00 05&lt;br /&gt;63 6F 75 6E 74 42 00 07 76 65 72 73 69 6F 6E 78&lt;br /&gt;70 00 64&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;If you look again at the actual &lt;code&gt;TestSerial&lt;/code&gt; object,  you'll see that it has only two byte members, as shown in Listing 5.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 5. TestSerial's byte members&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt; public byte version = 100;&lt;br /&gt; public byte count = 0;&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The size of a byte variable is one byte, and hence the total size of  the object (without the header) is two bytes. But if you look at the  size of the serialized object in Listing 4, you'll see 51 bytes.  Surprise! Where did the extra bytes come from, and what is their  significance? They are introduced by the serialization algorithm, and  are required in order to to re-create the object. In the next section,  you'll explore this algorithm in detail.&lt;/div&gt;&lt;h2 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Java's serialization algorithm&lt;/h2&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;By now, you should have a pretty good knowledge of how to serialize  an object. But how does the process work under the hood? In general the  serialization algorithm does the following:&lt;/div&gt;&lt;ul style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;li&gt;It writes out the metadata of the class associated with an instance.&lt;/li&gt;&lt;li&gt;It recursively writes out the description of the superclass until it  finds &lt;code&gt;java.lang.object&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Once it finishes writing the metadata information, it then starts  with the actual data associated with the instance. But this time, it  starts from the topmost superclass.&lt;/li&gt;&lt;li&gt;It recursively writes the data associated with the instance,  starting from the least superclass to the most-derived class. &lt;/li&gt;&lt;/ul&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;I've written a different example object for this section that will  cover all possible cases. The new sample object to be serialized is  shown in Listing 6.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 6. Sample serialized object&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;class parent implements Serializable {&lt;br /&gt; int parentVersion = 10;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class contain implements Serializable{&lt;br /&gt; int containVersion = 11;&lt;br /&gt;}&lt;br /&gt;public class SerialTest extends parent implements Serializable {&lt;br /&gt; int version = 66;&lt;br /&gt; contain con = new contain();&lt;br /&gt;&lt;br /&gt; public int getVersion() {&lt;br /&gt;  return version;&lt;br /&gt; }&lt;br /&gt; public static void main(String args[]) throws IOException {&lt;br /&gt;  FileOutputStream fos = new FileOutputStream("temp.out");&lt;br /&gt;  ObjectOutputStream oos = new ObjectOutputStream(fos);&lt;br /&gt;  SerialTest st = new SerialTest();&lt;br /&gt;  oos.writeObject(st);&lt;br /&gt;  oos.flush();&lt;br /&gt;  oos.close();&lt;br /&gt; }&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;This example is a straightforward one. It serializes an object of  type &lt;code&gt;SerialTest&lt;/code&gt;, which is derived from &lt;code&gt;parent&lt;/code&gt;  and has a container object, &lt;code&gt;contain&lt;/code&gt;. The serialized format  of this object is shown in Listing 7.&lt;/div&gt;&lt;h4 style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Listing 7. Serialized form of sample object&lt;/h4&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div class="codeblock"&gt;&lt;code&gt;AC ED 00 05 73 72 00 0A 53 65 72 69 61 6C 54 65&lt;br /&gt;73 74 05 52 81 5A AC 66 02 F6 02 00 02 49 00 07&lt;br /&gt;76 65 72 73 69 6F 6E 4C 00 03 63 6F 6E 74 00 09&lt;br /&gt;4C 63 6F 6E 74 61 69 6E 3B 78 72 00 06 70 61 72&lt;br /&gt;65 6E 74 0E DB D2 BD 85 EE 63 7A 02 00 01 49 00&lt;br /&gt;0D 70 61 72 65 6E 74 56 65 72 73 69 6F 6E 78 70&lt;br /&gt;00 00 00 0A 00 00 00 42 73 72 00 07 63 6F 6E 74&lt;br /&gt;61 69 6E FC BB E6 0E FB CB 60 C7 02 00 01 49 00&lt;br /&gt;0E 63 6F 6E 74 61 69 6E 56 65 72 73 69 6F 6E 78&lt;br /&gt;70 00 00 00 0B&lt;/code&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4414546624627978423?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4414546624627978423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4414546624627978423'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/03/java-serialization-algorithm-revealed.html' title='The Java serialization algorithm revealed'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-5850665217535034598</id><published>2010-03-12T12:05:00.000-08:00</published><updated>2010-03-27T12:07:40.656-07:00</updated><title type='text'>GWT XML Indenter/Formatter</title><content type='html'>&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;So while I was working on one of my outreach projects as a graduate  student, I wanted to write a simple XML indenter to make my GWT  generated xml more aesthetically appealing using &lt;strong&gt;stock&lt;/strong&gt;  GWT. The xml document is assumed to be as lean as possible (There are no  empty #text nodes that are usually in xml because of the indentation.)&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;I should also mention that I’m posting this because I didn’t really  see any stock simple GWT indenters after a quick google. The following  is not meant to be a complete indenter, just something quick and simple  to organize xml.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Here’s a &lt;b&gt;basic&lt;/b&gt; indenter.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="java" style="font-family: monospace;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;public&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #003399; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;String&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; formatXML&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Node node,&lt;/span&gt;&lt;span style="color: #003399; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;String&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; tab_str&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: #003399; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;String&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;""&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getNodeType&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;==&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ELEMENT_NODE&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: #003399; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;String&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; attributes&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;""&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="color: #000066; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; k&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="color: #cc66cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;k &lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getAttributes&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getLength&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;k&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;++&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;    attributes&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+=&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;" "&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getAttributes&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;item&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;k&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getNodeName&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"=&lt;span style="color: #000099; font-weight: bold;"&gt;\"&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getAttributes&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;item&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;k&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getNodeValue&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&lt;span style="color: #000099; font-weight: bold;"&gt;\"&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;tab_str&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&amp;lt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getNodeName&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;attributes&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&amp;gt;&lt;span style="color: #000099; font-weight: bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="color: #000066; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;int&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; i&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="color: #cc66cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;i&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getChildNodes&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getLength&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;i&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;++&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;    formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;formatXML&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getChildNodes&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;item&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;i&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;,tab_str&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"    "&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;tab_str&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&lt;!--"&lt;/span--&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;getNodeName&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&amp;gt;&lt;span style="color: #000099; font-weight: bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;   &lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;(&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;toString&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;trim&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;length&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc66cc; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;    formatted&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;=&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;tab_str&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;node.&lt;/span&gt;&lt;span style="color: #006633; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;toString&lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;()&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+&lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;"&lt;span style="color: #000099; font-weight: bold;"&gt;\n&lt;/span&gt;"&lt;/span&gt;&lt;span style="color: #339933; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;  &lt;/span&gt;&lt;span style="color: #009900; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: black; font-weight: bold;"&gt;return&lt;/span&gt; formatted&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #009900;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-5850665217535034598?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5850665217535034598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5850665217535034598'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/03/gwt-xml-indenterformatter.html' title='GWT XML Indenter/Formatter'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4690985171306231299</id><published>2010-02-25T23:29:00.000-08:00</published><updated>2010-02-25T23:29:41.800-08:00</updated><title type='text'>Playing with JVM / Java Heap Size.</title><content type='html'>&lt;img border="0" src="http://2.bp.blogspot.com/_5HuB87FNoE4/S4d3JOvAqhI/AAAAAAAAAAw/qp3iD1rIRa4/s320/java-logo.gif" style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 100px; height: 160px;" /&gt;&lt;span style="font-family:courier new;"&gt;Java programs executes in JVM uses Heap of memory to manage the data. If your Java program requires a large amount of memory, it is possible that the virtual machine will begin to throw OutOfMemoryError instances when attempting to instantiate an object. The default heap size if 1 MB and can increase as much as 16 MB.&lt;/span&gt;&lt;br /&gt;&lt;h2 style="font-family: courier new;"&gt;Setting/Increase JVM heap size&lt;/h2&gt;&lt;span style="font-family:courier new;"&gt;It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Following are few options available to change Heap Size.&lt;/span&gt;&lt;br /&gt;&lt;ol style="font-family: courier new;"&gt;&lt;li&gt;-Xms&amp;lt;size&amp;gt; set initial Java heap size&lt;/li&gt;&lt;li&gt;-Xmx&amp;lt;size&amp;gt; set maximum Java heap size&lt;/li&gt;&lt;li&gt;-Xss&amp;lt;size&amp;gt; set java thread stack size&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-family:courier new;"&gt;For example, you can set minimum heap to 64 MB and maximum heap 256 MB for a Java program HelloWorld.&lt;/span&gt;&lt;br /&gt;&lt;ol style="font-family: courier new;"&gt;&lt;li&gt;java -Xms64m -Xmx256m HelloWorld&lt;/li&gt;&lt;/ol&gt;&lt;h2 style="font-family: courier new;"&gt;Getting / Reading default heap size&lt;/h2&gt;&lt;span style="font-family:courier new;"&gt;It is possible to read the default JVM heap size programmatically by using totalMemory() method of Runtime class. Use following code to read JVM heap size.&lt;/span&gt;&lt;br /&gt;&lt;table width="794" border="0" cellpadding="0" cellspacing="0" style="font-family: courier new;"&gt;&lt;tbody&gt;&lt;tr&gt;  &lt;td width="445"&gt;public class GetHeapSize {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;    &amp;nbsp;&amp;nbsp;public static void main(String[]args){&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Get the jvm heap size.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long heapSize = Runtime.getRuntime().totalMemory();&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Print the jvm heap size.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Heap Size = " + heapSize);&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;    &amp;nbsp;&amp;nbsp;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4690985171306231299?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4690985171306231299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4690985171306231299'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/02/playing-with-jvm-java-heap-size.html' title='Playing with JVM / Java Heap Size.'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_5HuB87FNoE4/S4d3JOvAqhI/AAAAAAAAAAw/qp3iD1rIRa4/s72-c/java-logo.gif' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7058008847955423220</id><published>2010-02-23T14:02:00.000-08:00</published><updated>2010-02-23T23:08:22.040-08:00</updated><title type='text'>How to show each post’s date in WordPress</title><content type='html'>&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The templating system in WordPress is very flexible, and there's&amp;nbsp; rarely something you can't do or that doesn't work as you'd expect. A&amp;nbsp; notable exception however is &lt;a href="http://codex.wordpress.org/Template_Tags/the_date"&gt;the_date&lt;/a&gt;.&amp;nbsp; Its purpose is simple enough. It displays the current post's date of&amp;nbsp; creation. But on pages with more than one post (such as on many blog&amp;nbsp; home pages), something weird happens. If a number of posts on any given&amp;nbsp; page were created on the same date, the_date will only show&amp;nbsp; that date for the first of those posts.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;In the early days of blogging, posts were usually listed by date,&amp;nbsp; much like a regular, paper diary. In the old default theme that comes&amp;nbsp; with WordPress a big date title is used to separate posts into days.&amp;nbsp; That's what the_date was created to do, and so it makes&amp;nbsp; sense it only displays the same date once. In most modern themes&amp;nbsp; however, people like the date to be among the meta data for each&amp;nbsp; article, so the_date falls short.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7058008847955423220?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7058008847955423220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7058008847955423220'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/02/how-to-show-each-posts-date-in.html' title='How to show each post’s date in WordPress'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-5247934082429917256</id><published>2010-02-12T10:24:00.000-08:00</published><updated>2010-03-01T09:34:17.209-08:00</updated><title type='text'>ChromeOS gets more mature with Flow</title><content type='html'>&lt;div style="font-family: courier new;"&gt;It's been a while since I blogged about Chrome OS. Things have been pretty quiet around the Google-supported operating system for netbooks and tablets. But &lt;a href="http://chromeos.hexxeh.net/" target="_blank"&gt;Hexxeh&lt;/a&gt;, a 17&lt;sup&gt;th&lt;/sup&gt; year old developer who's been supplying pre-built versions of the OS for a while now, released an new version yesterday, and it's a lot more polished than earlier builds. It boots in seconds and runs pretty smoothly for a pre-alpha OS. If you're curious about Chrome OS, this is the perfect opportunity to give it a try.&lt;/div&gt;&lt;div style="font-family: courier new;"&gt;Not only is the '&lt;a href="http://chromeos.hexxeh.net/" target="_blank"&gt;Flow&lt;/a&gt;' build very easy to use, there are &lt;a href="http://chromeos.hexxeh.net/wiki/doku.php?id=windows_instructions" target="_blank"&gt;complete setup instructions&lt;/a&gt; as well. The OS is installed on a USB stick or an SD card (provided your target computer has a card reader it can boot from). It runs off of that drive, so nothing is left behind on the computer's hard drive. Simply take out the SD card and boot up to get back to Windows or whatever you were using before.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-5247934082429917256?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5247934082429917256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5247934082429917256'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/02/chromeos-gets-more-mature-with-flow.html' title='ChromeOS gets more mature with Flow'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7436708397081635239</id><published>2010-01-25T16:33:00.000-08:00</published><updated>2010-02-25T06:38:43.715-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Gzip Components</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The time it takes to transfer an HTTP request and response across the network can be significantly reduced by decisions made by front-end engineers. It's true that the end-user's bandwidth speed, Internet service provider, proximity to peering exchange points, etc. are beyond the control of the development team. But there are other variables that affect response times. Compression reduces response times by reducing the size of the HTTP response.&lt;br /&gt;&lt;br /&gt;Starting with HTTP/1.1, web clients indicate support for compression with the Accept-Encoding header in the HTTP request.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Accept-Encoding: gzip, deflate&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;If the web server sees this header in the request, it may compress the response using one of the methods listed by the client. The web server notifies the web client of this via the Content-Encoding header in the response.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Content-Encoding: gzip&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;Gzip is the most popular and effective compression method at this time. It was developed by the GNU project and standardized by &lt;a href="http://www.ietf.org/rfc/rfc1952.txt"&gt;RFC 1952&lt;/a&gt;. The only other compression format you're likely to see is deflate, but it's less effective and less popular. &lt;br /&gt;&lt;br /&gt;Gzipping generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip. If you use Apache, the module configuring gzip depends on your version: Apache 1.3 uses &lt;a href="http://sourceforge.net/projects/mod-gzip/"&gt;mod_gzip&lt;/a&gt; while Apache 2.x uses &lt;a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html"&gt;mod_deflate&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;There are known issues with browsers and proxies that may cause a mismatch in what the browser expects and what it receives with regard to compressed content. Fortunately, these edge cases are dwindling as the use of older browsers drops off. The Apache modules help out by adding appropriate Vary response headers automatically. &lt;br /&gt;&lt;br /&gt;Servers choose what to gzip based on file type, but are typically too limited in what they decide to compress. Most web sites gzip their HTML documents. It's also worthwhile to gzip your scripts and stylesheets, but many web sites miss this opportunity. In fact, it's worthwhile to compress any text response including XML and JSON. Image and PDF files should not be gzipped because they are already compressed. Trying to gzip them not only wastes CPU but can potentially increase file sizes. &lt;br /&gt;&lt;br /&gt;Gzipping as many file types as possible is an easy way to reduce page weight and accelerate the user experience.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7436708397081635239?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7436708397081635239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7436708397081635239'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2010/01/gzip-components.html' title='Best Practices for Speeding Up Your Web Site - Gzip Components'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4483255677278291393</id><published>2010-01-10T06:25:00.000-08:00</published><updated>2010-02-25T06:38:38.229-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Minimize HTTP Requests</title><content type='html'>&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;One way to reduce the number of components in the page is to simplify the page's design. But is there a way to build pages with richer content while also achieving fast response times? Here are some techniques for reducing the number of HTTP requests, while still supporting rich page designs.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;Combined files&lt;/b&gt; are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet. Combining files is more challenging when the scripts and stylesheets vary from page to page, but making this part of your release process improves response times.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://alistapart.com/articles/sprites"&gt;&lt;b&gt;CSS Sprites&lt;/b&gt;&lt;/a&gt; are the preferred method for reducing the number of image requests. Combine your background images into a single image and use the CSS background-image and background-position properties to display the desired image segment.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://www.w3.org/TR/html401/struct/objects.html#h-13.6"&gt;&lt;b&gt;Image maps&lt;/b&gt;&lt;/a&gt; combine multiple images into a single image. The overall size is about the same, but reducing the number of HTTP requests speeds up the page. Image maps only work if the images are contiguous in the page, such as a navigation bar. Defining the coordinates of image maps can be tedious and error prone. Using image maps for navigation is not accessible too, so it's not recommended.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;Inline images&lt;/b&gt; use the &lt;a href="http://tools.ietf.org/html/rfc2397"&gt;data: URL scheme&lt;/a&gt; to embed the image data in the actual page. This can increase the size of your HTML document. Combining inline images into your (cached) stylesheets is a way to reduce HTTP requests and avoid increasing the size of your pages. Inline images are not yet supported across all major browsers.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Reducing the number of HTTP requests in your page is the place to start. This is the most important guideline for improving performance for first time visitors. As described in Tenni Theurer's blog post &lt;a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/"&gt;Browser Cache Usage - Exposed!&lt;/a&gt;, 40-60% of daily visitors to your site come in with an empty cache. Making your page fast for these first time visitors is key to a better user experience.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4483255677278291393?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4483255677278291393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4483255677278291393'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/01/minimize-http-requests.html' title='Best Practices for Speeding Up Your Web Site - Minimize HTTP Requests'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-88000421071960961</id><published>2009-12-25T00:41:00.000-08:00</published><updated>2010-02-25T06:42:27.714-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Put Scripts at the Bottom</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;The problem caused by scripts is that they block parallel downloads. The &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1.4"&gt;HTTP/1.1 specification&lt;/a&gt; suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames. &lt;br /&gt;&lt;br /&gt;In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations.&lt;br /&gt;&lt;br /&gt;An alternative suggestion that often comes up is to use deferred scripts. The DEFER attribute indicates that the script does not contain document.write, and is a clue to browsers that they can continue rendering. Unfortunately, Firefox doesn't support the DEFER attribute. In Internet Explorer, the script may be deferred, but not as much as desired. If a script can be deferred, it can also be moved to the bottom of the page. That will make your web pages load faster.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-88000421071960961?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/88000421071960961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/88000421071960961'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/12/best-practices-for-speeding-up-your-web_25.html' title='Best Practices for Speeding Up Your Web Site - Put Scripts at the Bottom'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4867395515742723884</id><published>2009-12-12T10:39:00.000-08:00</published><updated>2010-02-25T06:41:06.736-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Put Stylesheets at the Top</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;While researching performance at Yahoo!, we discovered that moving stylesheets to the document HEAD makes pages &lt;em&gt;appear&lt;/em&gt; to be loading faster. This is because putting stylesheets in the HEAD allows the page to render progressively. &lt;br /&gt;&lt;br /&gt;Front-end engineers that care about performance want a page to load progressively; that is, we want the browser to display whatever content it has as soon as possible. This is especially important for pages with a lot of content and for users on slower Internet connections. The importance of giving users visual feedback, such as progress indicators, has been well researched and &lt;a href="http://www.useit.com/papers/responsetime.html"&gt;documented&lt;/a&gt;. In our case the HTML page is the progress indicator! When the browser loads the page progressively the header, the navigation bar, the logo at the top, etc. all serve as visual feedback for the user who is waiting for the page. This improves the overall user experience.&lt;br /&gt;&lt;br /&gt;The problem with putting stylesheets near the bottom of the document is that it prohibits progressive rendering in many browsers, including Internet Explorer. These browsers block rendering to avoid having to redraw elements of the page if their styles change. The user is stuck viewing a blank white page. &lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.w3.org/TR/html4/struct/links.html#h-12.3"&gt;HTML specification&lt;/a&gt; clearly states that stylesheets are to be included in the HEAD of the page: "Unlike A, [LINK] may only appear in the HEAD section of a document, although it may appear any number of times." Neither of the alternatives, the blank white screen or flash of unstyled content, are worth the risk. The optimal solution is to follow the HTML specification and load your stylesheets in the document HEAD.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4867395515742723884?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4867395515742723884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4867395515742723884'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/12/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Put Stylesheets at the Top'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-213084946479355323</id><published>2009-11-25T22:43:00.000-08:00</published><updated>2010-02-25T06:48:33.037-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Avoid CSS Expressions</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;CSS expressions are a powerful (and dangerous) way to set CSS properties dynamically. They're supported in Internet Explorer, starting with &lt;a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/recalc.asp"&gt;version 5&lt;/a&gt;. As an example, the background color could be set to alternate every hour using CSS expressions.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;background-color: expression( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );&lt;/pre&gt;&lt;br /&gt;As shown here, the expression method accepts a JavaScript expression. The CSS property is set to the result of evaluating the JavaScript expression. The expression method is ignored by other browsers, so it is useful for setting properties in Internet Explorer needed to create a consistent experience across browsers.&lt;br /&gt;&lt;br /&gt;The problem with expressions is that they are evaluated more frequently than most people expect. Not only are they evaluated when the page is rendered and resized, but also when the page is scrolled and even when the user moves the mouse over the page. Adding a counter to the CSS expression allows us to keep track of when and how often a CSS expression is evaluated. Moving the mouse around the page can easily generate more than 10,000 evaluations.&lt;br /&gt;&lt;br /&gt;One way to reduce the number of times your CSS expression is evaluated is to use one-time expressions, where the first time the expression is evaluated it sets the style property to an explicit value, which replaces the CSS expression. If the style property must be set dynamically throughout the life of the page, using event handlers instead of CSS expressions is an alternative approach. If you must use CSS expressions, remember that they may be evaluated thousands of times and could affect the performance of your page.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-213084946479355323?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/213084946479355323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/213084946479355323'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/11/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Avoid CSS Expressions'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-6475876915590837525</id><published>2009-11-09T00:48:00.000-08:00</published><updated>2010-02-25T06:51:37.103-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Make JavaScript and CSS External</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Many of these performance rules deal with how external components are managed. However, before these considerations arise you should ask a more basic question: Should JavaScript and CSS be contained in external files, or inlined in the page itself?&lt;br /&gt;&lt;br /&gt;Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests. &lt;br /&gt;&lt;br /&gt;The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files. &lt;br /&gt;&lt;br /&gt;Many web sites fall in the middle of these metrics. For these sites, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception where inlining is preferable is with home pages, such as Yahoo!'s front page and My Yahoo!. Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times.&lt;br /&gt;&lt;br /&gt;For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser's cache.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-6475876915590837525?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/6475876915590837525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/6475876915590837525'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/11/best-practices-for-speeding-up-your-web_09.html' title='Best Practices for Speeding Up Your Web Site - Make JavaScript and CSS External'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-2940935916526061683</id><published>2009-10-16T18:56:00.000-07:00</published><updated>2010-02-25T07:01:05.604-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Reduce DNS Lookups</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;"&gt;The Domain Name System (DNS) maps hostnames to IP addresses, just as phonebooks map people's names to their phone numbers. When you type www.yahoo.com into your browser, a DNS resolver contacted by the browser returns that server's IP address. DNS has a cost. It typically takes 20-120 milliseconds for DNS to lookup the IP address for a given hostname. The browser can't download anything from this hostname until the DNS lookup is completed. &lt;br /&gt;&lt;br /&gt;DNS lookups are cached for better performance. This caching can occur on a special caching server, maintained by the user's ISP or local area network, but there is also caching that occurs on the individual user's computer. The DNS information remains in the operating system's DNS cache (the "DNS Client service" on Microsoft Windows). Most browsers have their own caches, separate from the operating system's cache. As long as the browser keeps a DNS record in its own cache, it doesn't bother the operating system with a request for the record.&lt;br /&gt;&lt;br /&gt;Internet Explorer caches DNS lookups for 30 minutes by default, as specified by the DnsCacheTimeout registry setting. Firefox caches DNS lookups for 1 minute, controlled by the network.dnsCacheExpiration configuration setting. (Fasterfox changes this to 1 hour.)&lt;br /&gt;&lt;br /&gt;When the client's DNS cache is empty (for both the browser and the operating system), the number of DNS lookups is equal to the number of unique hostnames in the web page. This includes the hostnames used in the page's URL, images, script files, stylesheets, Flash objects, etc. Reducing the number of unique hostnames reduces the number of DNS lookups. &lt;br /&gt;&lt;br /&gt;Reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading that takes place in the page. Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times. My guideline is to split these components across at least two but no more than four hostnames. This results in a good compromise between reducing DNS lookups and allowing a high degree of parallel downloads.&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-2940935916526061683?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/2940935916526061683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/2940935916526061683'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/10/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Reduce DNS Lookups'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-5051504146804138514</id><published>2009-10-01T07:18:00.000-07:00</published><updated>2010-02-25T07:00:13.322-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Minify JavaScript and CSS</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are &lt;a href="http://crockford.com/javascript/jsmin"&gt;JSMin&lt;/a&gt; and &lt;a href="http://developer.yahoo.com/yui/compressor/"&gt;YUI Compressor&lt;/a&gt;. The YUI compressor can also minify CSS.&lt;br /&gt;&lt;br /&gt;Obfuscation is an alternative optimization that can be applied to source code. It's more complex than minification and thus more likely to generate bugs as a result of the obfuscation step itself. In a survey of ten top U.S. web sites, minification achieved a 21% size reduction versus 25% for obfuscation. Although obfuscation has a higher size reduction, minifying JavaScript is less risky.&lt;br /&gt;&lt;br /&gt;In addition to minifying external scripts and styles, inlined &amp;lt;script&amp;gt; and &amp;lt;style&amp;gt; blocks can and should also be minified. Even if you gzip your scripts and styles, minifying them will still reduce the size by 5% or more. As the use and size of JavaScript and CSS increases, so will the savings gained by minifying your code.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-5051504146804138514?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5051504146804138514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5051504146804138514'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/10/best-practices-for-speeding-up-your-web_01.html' title='Best Practices for Speeding Up Your Web Site - Minify JavaScript and CSS'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7719333335136741772</id><published>2009-09-25T04:01:00.000-07:00</published><updated>2010-02-25T07:04:08.175-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Avoid Redirects</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Redirects are accomplished using the 301 and 302 status codes. Here's an example of the HTTP headers in a 301 response:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;HTTP/1.1 301 Moved Permanently Location: http://example.com/newuri Content-Type: text/html&lt;/pre&gt;&lt;br /&gt;The browser automatically takes the user to the URL specified in the Location field. All the information necessary for a redirect is in the headers. The body of the response is typically empty. Despite their names, neither a 301 nor a 302 response is cached in practice unless additional headers, such as Expires or Cache-Control, indicate it should be. The meta refresh tag and JavaScript are other ways to direct users to a different URL, but if you must do a redirect, the preferred technique is to use the standard 3xx HTTP status codes, primarily to ensure the back button works correctly.&lt;br /&gt;&lt;br /&gt;The main thing to remember is that redirects slow down the user experience. Inserting a redirect between the user and the HTML document delays everything in the page since nothing in the page can be rendered and no components can start being downloaded until the HTML document has arrived.&lt;br /&gt;&lt;br /&gt;One of the most wasteful redirects happens frequently and web developers are generally not aware of it. It occurs when a trailing slash (/) is missing from a URL that should otherwise have one. For example, going to &lt;a href="http://astrology.advancedmicrodevices.org/astrology"&gt;http://astrology.advancedmicrodevices.org/astrology&lt;/a&gt; results in a 301 response containing a redirect to &lt;a href="http://astrology.advancedmicrodevices.org/astrology/"&gt;http://astrology.advancedmicrodevices.org/astrology/&lt;/a&gt; (notice the added trailing slash). This is fixed in Apache by using Alias or mod_rewrite, or the DirectorySlash directive if you're using Apache handlers.&lt;br /&gt;&lt;br /&gt;Connecting an old web site to a new one is another common use for redirects. Others include connecting different parts of a website and directing the user based on certain conditions (type of browser, type of user account, etc.). Using a redirect to connect two web sites is simple and requires little additional coding. Although using redirects in these situations reduces the complexity for developers, it degrades the user experience. Alternatives for this use of redirects include using Alias and mod_rewrite if the two code paths are hosted on the same server. If a domain name change is the cause of using redirects, an alternative is to create a CNAME (a DNS record that creates an alias pointing from one domain name to another) in combination with Alias or mod_rewrite.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7719333335136741772?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7719333335136741772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7719333335136741772'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/09/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Avoid Redirects'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4078374872651441448</id><published>2009-09-18T07:04:00.000-07:00</published><updated>2010-02-25T07:09:02.165-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Remove Duplicate Scripts</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;t hurts performance to include the same JavaScript file twice in one page. This isn't as unusual as you might think. A review of the ten top U.S. web sites shows that two of them contain a duplicated script. Two main factors increase the odds of a script being duplicated in a single web page: team size and number of scripts. When it does happen, duplicate scripts hurt performance by creating unnecessary HTTP requests and wasted JavaScript execution.&lt;br /&gt;&lt;br /&gt;Unnecessary HTTP requests happen in Internet Explorer, but not in Firefox. In Internet Explorer, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page.&lt;br /&gt;&lt;br /&gt;In addition to generating wasteful HTTP requests, time is wasted evaluating the script multiple times. This redundant JavaScript execution happens in both Firefox and Internet Explorer, regardless of whether the script is cacheable.&lt;br /&gt;&lt;br /&gt;One way to avoid accidentally including the same script twice is to implement a script management module in your templating system. The typical way to include a script is to use the SCRIPT tag in your HTML page.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;script type="text/javascript" src="menu_1.0.17.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;An alternative in PHP would be to create a function called insertScript.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;?php insertScript("menu.js") ?&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;In addition to preventing the same script from being inserted multiple times, this function could handle other issues with scripts, such as dependency checking and adding version numbers to script filenames to support far future Expires headers.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4078374872651441448?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4078374872651441448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4078374872651441448'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/02/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Remove Duplicate Scripts'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7596269557706240979</id><published>2009-08-25T02:06:00.000-07:00</published><updated>2010-02-25T07:08:26.533-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Reduce the Number of DOM Elements</title><content type='html'>A complex page means more bytes to download and it also means slower DOM access in JavaScript. It makes a difference if you loop through 500 or 5000 DOM elements on the page when you want to add an event handler for example. &lt;br /&gt;&lt;br /&gt;A high number of DOM elements can be a symptom that there's something that should be improved with the markup of the page without necessarily removing content. Are you using nested tables for layout purposes? Are you throwing in more &amp;lt;div&amp;gt;s only to fix layout issues? Maybe there's a better and more semantically correct way to do your markup. &lt;br /&gt;&lt;br /&gt;A great help with layouts are the &lt;a href="http://developer.yahoo.com/yui/"&gt;YUI CSS utilities&lt;/a&gt;: grids.css can help you with the overall layout, fonts.css and reset.css can help you strip away the browser's defaults formatting. This is a chance to start fresh and think about your markup, for example use &amp;lt;div&amp;gt;s only when it makes sense semantically, and not because it renders a new line. &lt;br /&gt;&lt;br /&gt;The number of DOM elements is easy to test, just type in Firebug's console:&lt;br /&gt;document.getElementsByTagName('*').length &lt;br /&gt;&lt;br /&gt;And how many DOM elements are too many? Check other similar pages that have good markup. For example the &lt;a href="http://www.yahoo.com/"&gt;Yahoo! Home Page&lt;/a&gt; is a pretty busy page and still under 700 elements (HTML tags). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;A complex page means more bytes to download and it also means slower DOM access in JavaScript. It makes a difference if you loop through 500 or 5000 DOM elements on the page when you want to add an event handler for example. &lt;br /&gt;&lt;br /&gt;A high number of DOM elements can be a symptom that there's something that should be improved with the markup of the page without necessarily removing content. Are you using nested tables for layout purposes? Are you throwing in more &amp;lt;div&amp;gt;s only to fix layout issues? Maybe there's a better and more semantically correct way to do your markup. &lt;br /&gt;&lt;br /&gt;A great help with layouts are the &lt;a href="http://developer.yahoo.com/yui/"&gt;YUI CSS utilities&lt;/a&gt;: grids.css can help you with the overall layout, fonts.css and reset.css can help you strip away the browser's defaults formatting. This is a chance to start fresh and think about your markup, for example use &amp;lt;div&amp;gt;s only when it makes sense semantically, and not because it renders a new line. &lt;br /&gt;&lt;br /&gt;The number of DOM elements is easy to test, just type in Firebug's console:&lt;br /&gt;document.getElementsByTagName('*').length &lt;br /&gt;&lt;br /&gt;And how many DOM elements are too many? Check other similar pages that have good markup. For example the &lt;a href="http://www.yahoo.com/"&gt;Yahoo! Home Page&lt;/a&gt; is a pretty busy page and still under 700 elements (HTML tags).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7596269557706240979?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7596269557706240979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7596269557706240979'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/08/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Reduce the Number of DOM Elements'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4293076826634044782</id><published>2009-08-01T07:10:00.000-07:00</published><updated>2010-02-25T07:12:32.174-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Minimize the Number of iframes</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; Iframes allow an HTML document to be inserted in the parent document. It's important to understand how iframes work so they can be used effectively. &lt;br /&gt;&lt;br /&gt;&amp;lt;iframe&amp;gt; pros: &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&amp;nbsp;&lt;li&gt;Helps with slow third-party content like badges and ads&lt;/li&gt;&amp;nbsp;&lt;li&gt;Security sandbox&lt;/li&gt;&amp;nbsp;&lt;li&gt;Download scripts in parallel&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&amp;lt;iframe&amp;gt; cons: &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&amp;nbsp;&lt;li&gt;Costly even if blank&lt;/li&gt;&amp;nbsp;&lt;li&gt;Blocks page onload&lt;/li&gt;&amp;nbsp;&lt;li&gt;Non-semantic&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4293076826634044782?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4293076826634044782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4293076826634044782'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/08/best-practices-for-speeding-up-your-web_01.html' title='Best Practices for Speeding Up Your Web Site - Minimize the Number of iframes'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-1368272989524185680</id><published>2009-07-25T07:12:00.000-07:00</published><updated>2010-02-25T07:14:03.465-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - No 404s</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; HTTP requests are expensive so making an HTTP request and getting a useless response (i.e. 404 Not Found) is totally unnecessary and will slow down the user experience without any benefit. &lt;br /&gt;&lt;br /&gt;Some sites have helpful 404s "Did you mean X?", which is great for the user experience but also wastes server resources (like database, etc). Particularly bad is when the link to an external JavaScript is wrong and the result is a 404. First, this download will block parallel downloads. Next the browser may try to parse the 404 response body as if it were JavaScript code, trying to find something usable in it. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-1368272989524185680?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/1368272989524185680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/1368272989524185680'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/07/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - No 404s'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-5322204743316988408</id><published>2009-07-18T01:14:00.000-07:00</published><updated>2010-02-25T07:16:18.233-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Reduce Cookie Size</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; HTTP cookies are used for a variety of reasons such as authentication and personalization. Information about cookies is exchanged in the HTTP headers between web servers and browsers. It's important to keep the size of cookies as low as possible to minimize the impact on the user's response time. &lt;br /&gt;&lt;br /&gt;For more information check &lt;a href="http://yuiblog.com/blog/2007/03/01/performance-research-part-3/"&gt;"When the Cookie Crumbles"&lt;/a&gt; by Tenni Theurer and Patty Chi. The take-home of this research: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&amp;nbsp;&lt;li&gt;Eliminate unnecessary cookies&lt;/li&gt;&amp;nbsp;&lt;li&gt;Keep cookie sizes as low as possible to minimize the impact on the user response time&lt;/li&gt;&amp;nbsp;&lt;li&gt;Be mindful of setting cookies at the appropriate domain level so other sub-domains are not affected&lt;/li&gt;&amp;nbsp;&lt;li&gt;Set an Expires date appropriately. An earlier Expires date or none removes the cookie sooner, improving the user response time&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-5322204743316988408?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5322204743316988408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/5322204743316988408'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/07/best-practices-for-speeding-up-your-web_18.html' title='Best Practices for Speeding Up Your Web Site - Reduce Cookie Size'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-4997904375872874282</id><published>2009-06-17T04:19:00.000-07:00</published><updated>2010-02-25T07:21:13.103-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Minimize DOM Access</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; Accessing DOM elements with JavaScript is slow so in order to have a more responsive page, you should: &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&amp;nbsp;&lt;li&gt;Cache references to accessed elements&lt;/li&gt;&amp;nbsp;&lt;li&gt;Update nodes "offline" and then add them to the tree&lt;/li&gt;&amp;nbsp;&lt;li&gt;Avoid fixing layout with JavaScript&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-4997904375872874282?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4997904375872874282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/4997904375872874282'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/06/best-practices-for-speeding-up-your-web_17.html' title='Best Practices for Speeding Up Your Web Site - Minimize DOM Access'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-950621314800644145</id><published>2009-06-01T11:17:00.000-07:00</published><updated>2010-02-25T07:19:47.276-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Use Cookie-free Domains for Components</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; When the browser makes a request for a static image and sends cookies together with the request, the server doesn't have any use for those cookies. So they only create network traffic for no good reason. You should make sure static components are requested with cookie-free requests. Create a subdomain and host all your static components there. &lt;br /&gt;&lt;br /&gt;If your domain is www.example.org, you can host your static components on static.example.org. However, if you've already set cookies on the top-level domain example.org as opposed to www.example.org, then all the requests to static.example.org will include those cookies. In this case, you can buy a whole new domain, host your static components there, and keep this domain cookie-free. Yahoo! uses yimg.com, YouTube uses ytimg.com, Amazon uses images-amazon.com and so on. &lt;br /&gt;&lt;br /&gt;Another benefit of hosting static components on a cookie-free domain is that some proxies might refuse to cache the components that are requested with cookies. On a related note, if you wonder if you should use example.org or www.example.org for your home page, consider the cookie impact. Omitting www leaves you no choice but to write cookies to *.example.org, so for performance reasons it's best to use the www subdomain and write the cookies to that subdomain. &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-950621314800644145?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/950621314800644145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/950621314800644145'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/06/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Use Cookie-free Domains for Components'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-547687937821307005</id><published>2009-05-28T07:25:00.000-07:00</published><updated>2010-02-25T07:27:35.478-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Avoid Filters</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; The IE-proprietary AlphaImageLoader filter aims to fix a problem with semi-transparent true color PNGs in IE versions &amp;lt; 7. The problem with this filter is that it blocks rendering and freezes the browser while the image is being downloaded. It also increases memory consumption and is applied per element, not per image, so the problem is multiplied. &lt;br /&gt;&lt;br /&gt;The best approach is to avoid AlphaImageLoader completely and use gracefully degrading PNG8 instead, which are fine in IE. If you absolutely need AlphaImageLoader, use the underscore hack _filter as to not penalize your IE7+ users. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-547687937821307005?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/547687937821307005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/547687937821307005'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/05/best-practices-for-speeding-up-your-web_28.html' title='Best Practices for Speeding Up Your Web Site - Avoid Filters'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7502276345896257188</id><published>2009-05-02T00:21:00.000-07:00</published><updated>2010-02-25T07:23:38.191-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Choose &lt;link&gt; over @import</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; One of the previous best practices states that CSS should be at the top in order to allow for progressive rendering. &lt;br /&gt;&lt;br /&gt;In IE @import behaves the same as using &amp;lt;link&amp;gt; at the bottom of the page, so it's best not to use it. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7502276345896257188?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7502276345896257188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7502276345896257188'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/05/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Choose &amp;lt;link&amp;gt; over @import'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7560493214779861676</id><published>2009-04-25T08:35:00.000-07:00</published><updated>2010-02-25T07:36:25.935-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Don't Scale Images in HTML</title><content type='html'>&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Don't use a bigger image than you need just because you can set the width and height in HTML. If you need &lt;br /&gt;&amp;lt;img width="100" height="100" src="mycat.jpg" alt="My Cat" /&amp;gt; &lt;br /&gt;then your image (mycat.jpg) should be 100x100px rather than a scaled down 500x500px image.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7560493214779861676?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7560493214779861676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7560493214779861676'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/04/best-practices-for-speeding-up-your-web_25.html' title='Best Practices for Speeding Up Your Web Site - Don&apos;t Scale Images in HTML'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-7332707626380662548</id><published>2009-04-07T05:32:00.000-07:00</published><updated>2010-02-25T07:34:55.481-08:00</updated><title type='text'>Best Practices for Speeding Up Your Web Site - Optimize Images</title><content type='html'>&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;After a designer is done with creating the images for your web page, there are still some things you can try before you FTP those images to your web server. &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&amp;nbsp;&lt;li&gt;You can check the GIFs and see if they are using a palette size corresponding to the number of colors in the image. Using &lt;a href="http://www.imagemagick.org/"&gt;imagemagick&lt;/a&gt; it's easy to check using &lt;br /&gt;identify -verbose image.gif &lt;br /&gt;When you see an image useing 4 colors and a 256 color "slots" in the palette, there is room for improvement. &lt;/li&gt;&amp;nbsp;&lt;li&gt; Try converting GIFs to PNGs and see if there is a saving. More often than not, there is. Developers often hesitate to use PNGs due to the limited support in browsers, but this is now a thing of the past. The only real problem is alpha-transparency in true color PNGs, but then again, GIFs are not true color and don't support variable transparency either. So anything a GIF can do, a palette PNG (PNG8) can do too (except for animations). This simple imagemagick command results in totally safe-to-use PNGs:&lt;br /&gt;convert image.gif image.png &lt;br /&gt;"All we are saying is: Give PiNG a Chance!" &lt;/li&gt;&amp;nbsp;&lt;li&gt; Run &lt;a href="http://pmt.sourceforge.net/pngcrush/"&gt;pngcrush&lt;/a&gt; (or any other PNG optimizer tool) on all your PNGs. Example: &lt;br /&gt;pngcrush image.png -rem alla -reduce -brute result.png &lt;/li&gt;&amp;nbsp;&lt;li&gt; Run jpegtran on all your JPEGs. This tool does lossless JPEG operations such as rotation and can also be used to optimize and remove comments and other useless information (such as EXIF information) from your images. &lt;br /&gt;jpegtran -copy none -optimize -perfect src.jpg dest.jpg &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-7332707626380662548?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7332707626380662548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/7332707626380662548'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/04/best-practices-for-speeding-up-your-web.html' title='Best Practices for Speeding Up Your Web Site - Optimize Images'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-7746785397689385135.post-3187284858596594111</id><published>2009-03-09T23:39:00.000-07:00</published><updated>2010-02-25T23:40:01.742-08:00</updated><title type='text'>20 very useful Eclipse IDE Shortcuts for Developers</title><content type='html'>&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/div&gt;Eclipse have been my favorite Java IDE since I started coding in&amp;nbsp; Java. Shortcuts makes life very easy when you are working with any IDE.&amp;nbsp; Eclipse also comes with lot of shortcuts that makes like of a developer&amp;nbsp; easy. &lt;br /&gt;&lt;br /&gt;Following are few shortcuts of my choice. &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + Shift + O&lt;/strong&gt; : Organize imports&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + /&lt;/strong&gt; : Line Comment&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + Shift + T&lt;/strong&gt; : Open Type&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + O&lt;/strong&gt; : Open declarations&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + E&lt;/strong&gt; : Open Editor&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + Shift + F4&lt;/strong&gt; : Close all Opened Editors&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + R&lt;/strong&gt; : Rename&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + L&lt;/strong&gt; : Extract to Local Variable&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + M&lt;/strong&gt; : Extract to Method&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;F3&lt;/strong&gt; : Open Declaration&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + X&lt;/strong&gt; : Run As…&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + D&lt;/strong&gt; : Debug As…&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + W&lt;/strong&gt; : show the class in the package view.&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + T&lt;/strong&gt; : Type hierarchy&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl+Q&lt;/strong&gt; : Last edit&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Left&lt;/strong&gt; or &lt;strong&gt;Alt + Right&lt;/strong&gt; : Navigate Left and Right&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + 1&lt;/strong&gt; : Quick Fix&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Ctrl + Space&lt;/strong&gt; : Content Assist&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + F&lt;/strong&gt; : Format code&lt;/li&gt;&amp;nbsp;&lt;li&gt;&lt;strong&gt;Alt + Shift + S + R&lt;/strong&gt; : Generate getter and setter methods &lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7746785397689385135-3187284858596594111?l=advancedmicrodevicesorg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/3187284858596594111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7746785397689385135/posts/default/3187284858596594111'/><link rel='alternate' type='text/html' href='http://advancedmicrodevicesorg.blogspot.com/2009/03/20-very-useful-eclipse-ide-shortcuts.html' title='20 very useful Eclipse IDE Shortcuts for Developers'/><author><name>AmitTechSol.com</name><uri>http://www.blogger.com/profile/14199955270929927155</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
