In this part, we will look into the main building blocks of Ajax and how to optimize them for Search Engine Optimization one by one. In fact, I will not get into details of the working of Ajax itself as it is beyond the scope of this writing. I will try to avoid going too much technical here, rather a simple and clean approach will be used to convey the concept and underlying impacts accordingly. After reading this “SEO for Ajax – part 3”, I hope it would become easier for an SEO expert to implement the items with the coordination of his development team members and architects.
alert("Record has been saved successfully");
you could set a global variable, like this:
message=" Record has been saved successfully ";
to serve as a string constant and then replace the recurring strings in the various calls as follows:
alert(message);
You can even show some extended messages based on the original macro as:
alert(message +": Please create a new record now");
There is one care with this technique. It is necessary that you make sure the string is used very often so that macro makes sense
var str = "Row number " +
x +
" has invalid date";
you can write this:
var str=" Row number "+x+" has invalid date";
Be careful when condensing, however. JavaScript treats line breaks as implicit semicolons.
If you do not finish lines with semicolons, you may find yourself in trouble and your code can mess up. For example, the following well formed JavaScript uses implied semicolons:
a=a+1
b=b+1
A simple whitespace remover tool might produce this:
a=a+1b=b+1
This code will throw an error. But if you add in the needed semicolons, the code will work:
x=x+1;y=y+1;
code. For example, given chunk of if statements and several loops that contain only a
single statement, you can remove the braces, so this:
if (isActive)
{
alert("You card is Active");
}
becomes this:
if (isActive)
alert("You card is Active");
As another size reduction example, you also can eliminate a return statement with no
argument just before the end of a function. So, this:
function doProcess( )
{
/* code here*/
return;
}
becomes this:
function doProcess ( )
{
/* code here */
}
There are also some good tools available out there that you can employ for byte saving tricks to tune code, but generally this tool is recommended for such things. http://www.w3compiler.com. All above techniques may only save a small portion of the total file size but every byte counts from SEO perspective. In fact, Google will consider loading time and fast response from server a major SEO factor to be considered in search result for year 2010. So never ignore anything which is helpful in reducing the file size on the client machine.
value1,value2,value3,...value N
If you encoded the same data in XML, it would be much heavier:
In the case of an Ajax based application, the data sent and consumed is often very small and is textual in nature, so it can be HTTP compressed plainly for transmission. XML primarily considered the fundamental part of AJAX is not considered a very good option from one school of developers and they are quite right in making that opinion. First, XML is bulky as compared to other lighter formats. Second, there is the too much DOM code that is required to deal with parsing out the response. Finally, because browsers generally are not behaving as validating XML parsers but instead focus only on well formedness, the semantic value of XML is rather wasted. As a replacement to XML, many Ajax developers favor to use JSON, available at http://www.json.org. JSON is a lightweight data exchange format that is based on a subset of the Javascript. Because it is a subset of Javascript, we can simply convert a JSON response into something that the receiving script can manipulate directly.
For instance, we may return as below, which is a valid JSON array:
["item1","item2","item3","item4"]
Or we may return a JSON object such as:
{"Status": "Active", "Amount" : "$5000" , "Expire" : "15/05/2010" }
If this were found in the responseText property of an XmlHttpRequest object, we might speedily make it accessible for use by means of below mentioned code:
var output = eval(xhr.responseText);
Now you would be able to reference the individual values in the output object as:
var str = "Status of card is " + output.Status + " and transaction amount is "+ output.Amount + ", Card will Expire on " + output.Expire;
OK, that’s enough for now, take a long breath and get ready for 4th and Final Part of this SEO for Ajax series.
JavaScript Optimization
There is a good amount of use of Javascript in Ajax, you should focus on improving your use of JavaScript to reduce your download footprint. Authors of such javascript libraries do understand the JavaScript bloat problem. They present their code in a standard, completely commented and maintainable version as well as in a minified version. You should have an understanding of minification and how it works. It is possible that there will be code outside your library that will require to be compressed as well.Remove JavaScript Comments
You can safely get rid of all JavaScript comments that serves no purpose. As these add extra bytes to the code, so eliminate them from your code to reduce the overall size. These are indicated by // or /* */. They also offer no value to the end user and just add to file size. You also need to know the conditional commenting system of IE browser that is frequently used with “includes” or Cascading Style Sheets (CSS). You should not remove these conditional comments from your code because you may otherwise unintentionally break your Javascript. Fortunately, many advance tools for page optimization know this criterion, and will not flag that up.String Constant Macros – A good approach
If you find in your code that their are repeating occurrences of strings or a complete strings over and over again, you can substitute a simple string macro using a global variable remapping can reduce a number of bytes. For example, if you have a number of alert( ) invocations in your program, like this:alert("Record has been saved successfully");
you could set a global variable, like this:
message=" Record has been saved successfully ";
to serve as a string constant and then replace the recurring strings in the various calls as follows:
alert(message);
You can even show some extended messages based on the original macro as:
alert(message +": Please create a new record now");
There is one care with this technique. It is necessary that you make sure the string is used very often so that macro makes sense
What you need to do with Whitespaces
JavaScript ignores the white spaces so you can easily decrease the whitespace between operators. For example, instead of writing this:var str = "Row number " +
x +
" has invalid date";
you can write this:
var str=" Row number "+x+" has invalid date";
Be careful when condensing, however. JavaScript treats line breaks as implicit semicolons.
If you do not finish lines with semicolons, you may find yourself in trouble and your code can mess up. For example, the following well formed JavaScript uses implied semicolons:
a=a+1
b=b+1
A simple whitespace remover tool might produce this:
a=a+1b=b+1
This code will throw an error. But if you add in the needed semicolons, the code will work:
x=x+1;y=y+1;
Avoid Constructs - Little reduction in Size
In many conditions, you can get rid of code and syntax constructs without hurting thecode. For example, given chunk of if statements and several loops that contain only a
single statement, you can remove the braces, so this:
if (isActive)
{
alert("You card is Active");
}
becomes this:
if (isActive)
alert("You card is Active");
As another size reduction example, you also can eliminate a return statement with no
argument just before the end of a function. So, this:
function doProcess( )
{
/* code here*/
return;
}
becomes this:
function doProcess ( )
{
/* code here */
}
There are also some good tools available out there that you can employ for byte saving tricks to tune code, but generally this tool is recommended for such things. http://www.w3compiler.com. All above techniques may only save a small portion of the total file size but every byte counts from SEO perspective. In fact, Google will consider loading time and fast response from server a major SEO factor to be considered in search result for year 2010. So never ignore anything which is helpful in reducing the file size on the client machine.
XML vs JSON – Choice is yours
Ajax requests may be tiny as compared to the conventional full post backs, but there definitely are differences with various data formats used with Ajax itself, particularly if you consider the included content vs. the structural markup. For example, consider that when a request is made with simple list of comma separated values, any returned data will be pretty concise:value1,value2,value3,...value N
If you encoded the same data in XML, it would be much heavier:
<?xml version="1.0" encoding="UTF-8" ?>
<docElement>
<package>Value 1</ package >
< package >Value 2</package>
...
< package >Value N</ package >
</docElement>
<docElement>
<package>Value 1</ package >
< package >Value 2</package>
...
< package >Value N</ package >
</docElement>
In the case of an Ajax based application, the data sent and consumed is often very small and is textual in nature, so it can be HTTP compressed plainly for transmission. XML primarily considered the fundamental part of AJAX is not considered a very good option from one school of developers and they are quite right in making that opinion. First, XML is bulky as compared to other lighter formats. Second, there is the too much DOM code that is required to deal with parsing out the response. Finally, because browsers generally are not behaving as validating XML parsers but instead focus only on well formedness, the semantic value of XML is rather wasted. As a replacement to XML, many Ajax developers favor to use JSON, available at http://www.json.org. JSON is a lightweight data exchange format that is based on a subset of the Javascript. Because it is a subset of Javascript, we can simply convert a JSON response into something that the receiving script can manipulate directly.
For instance, we may return as below, which is a valid JSON array:
["item1","item2","item3","item4"]
Or we may return a JSON object such as:
{"Status": "Active", "Amount" : "$5000" , "Expire" : "15/05/2010" }
If this were found in the responseText property of an XmlHttpRequest object, we might speedily make it accessible for use by means of below mentioned code:
var output = eval(xhr.responseText);
Now you would be able to reference the individual values in the output object as:
var str = "Status of card is " + output.Status + " and transaction amount is "+ output.Amount + ", Card will Expire on " + output.Expire;
OK, that’s enough for now, take a long breath and get ready for 4th and Final Part of this SEO for Ajax series.
. You can easily procure Search engine optimisation services so that users find it easy to find your site. If you are looking out for companies that provide SEO services India based, there are a large number of companies like trafficwala.com which are sure to make your business grow. The actual trick is to discover the right kind of keywords for your kind of business so that you attract users who can be potential customers. This thing as it sounds is not difficult at all, you can use various keyword research tools available free of cost on the web and which results in producing product oriented keywords which will only be found at your site
ReplyDeleteThank you for understanding the limits of your readers. Not all of us are very technical person when it comes to web designing, developing, XML codes and stuff. You’ve made the article simple and easy for us to understand.
ReplyDeleteseo
more compatible one taht will suit to the site design and layout.
ReplyDelete____________
seo package
Author
ReplyDeleteThanks a lot for make this great blog.
Please keep posting
Hi Frnds,
ReplyDeleteI would like to give information about article website, where you can submit instant article. No need to resister. Just publish your article with single click. http://www.instantarticles.net
Thanks & Regards
Admin
yes thats nice information for us........
ReplyDeleteRegards
E-commerce
Quite informative post, will surely try to implement the process.
ReplyDeleteWebsite Marketing Company
Hey all, I found a good site for those wondering about the intricacies of the dental school experience:seo marketing company
ReplyDeletegood news
ReplyDeleteAfter reading your post, i think its a fresh news for everyone.
------
Thanks
SEO India
Very informative post. Thanks for sharing the code details too here very clearly. The explanation was so clear and concise. Definitely worth reading article for seo.
ReplyDeleteRegards,
seo company india
I have some Best Dofollow Social bookmarking which are really helpful in your keywords ranking
ReplyDeletehttp://www.web-promotion-services.info
http://www.allbusiness-news.info
http://www.your-bookmarks.co.cc
http://www.submityourstory.co.cc
http://www.diggyourstory.co.cc
http://www.123webs.co.cc
http://www.twitterbookmark.co.cc
http://www.1stgreatnews.co.cc
http://www.usa-bookmarks.co.cc
http://www.123-news.co.cc
doing seo for Ajax website is little hard, but the tips describe in the post are very effective and i think that will work. Thanks
ReplyDeleteWow, one of the best read posts so far.
ReplyDeleteNice Commenting, i want to appreciate u that u have share right information about SEO optimization Services and different type of services regarding SEO
ReplyDeleteThanks
SEO Services India
Hi,
ReplyDeleteThanks for sharing the whole information and this is very useful for us.
San Francisco SEO
I read this post. It looks interesting. Please keep posting.
ReplyDeleteuse gzip to compress js script is also a good way.
ReplyDeleteseo tips
This is really a nice blog. It helped me to get valuable informations. I really appreciate.
ReplyDeleteGreat Post, Very Informative.
ReplyDeleteKeep Up The Good Work!
Best Regards.
great work .. goood job.. i liked the layout of your blog very much. you can get free seo tools and domain name along with web hosting at www.hostdomainshere.com.
ReplyDeleteI was looking for information about SEO and ur blog is great, ur post is great, it's clear, helpful and so interesting. Good job!
ReplyDeleteWell, the SEO information which you have given is very good, i have the same SEO material blog. Hope this will help to the SEO beginners.
ReplyDeleteGreat post, this article contains how marketing should be done, will save post and share. affordable seo
ReplyDeleteReally informative, the Javascript part was an interesting fact to know.
ReplyDeleteWebsite Designing
it's really nice post.i think new days going to make a stable seo technique like link building....
ReplyDeleteI can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success.
ReplyDeletenice article.......
ReplyDeleteby this i got some knolodege on that.....
yhanq u .......
keep going
"Seo information blog"
ReplyDeletethis blog contain good information..
by going through ur blog i was able to learn many new things........
thanq u...
Great post! You have some brilliant contents!
ReplyDeleteIt is great to read some of the information and feedback, here. I hope to read more ideas in the future!!!
ReplyDeleteI recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
ReplyDeleteThank you for understanding the limits of your readers. Not all of us are very technical person when it comes to web designing, developing, XML codes and stuff. You’ve made the article simple and easy for us to understand.
ReplyDeleteseo
I absolutely loved the book. It was unpredictable, very visual and it was unique. Although I find the author a little bit odd, (He blogs about the weirdest things) The Maze Runner was amazing. Thanks ;)
ReplyDeleteThanks for the post. It is very informative. I get to know various things from this post. Keep posting like this.
ReplyDeleteReally great and informative post by you... i appreciate your effort taken for the same.
ReplyDeleteThanks For Sharing.
SEO Freelancer India
doing seo for Ajax website is little hard, but the tips describe in the post are very effective and i think that will work. Thanks
ReplyDeleteReally your information is very helpful for everybody who work of seo.It's a great job.
ReplyDeleteGreat post!. It's clear, helpful and so interesting.
ReplyDeletehmmm very interesting though , helpful in the sense to understand the programming aspect of seo optimization..............
ReplyDeleteVery good article, If any company follows these steps than it would become easier for an SEO expert to implement the items with the coordination of his development team members and architects. Also, the use of coding had helped us understand your point in a very precise way.
ReplyDeleteWow! Very informative blog you have shared, doing seo for Ajax website is little hard, but the tips describe in the post are very effective and i think that will work. Thanks
ReplyDeleteReally nice and honest advice! i love it, absolutely brilliant.....
ReplyDeletenice blog
ReplyDeleteThanks a for this informative post. this mistakes looks small but create big problem to search engine so always be careful while constructing websites.....
ReplyDeleteSmith ALan
Ajax is very helpful SEO techniques.
ReplyDeleteThanks
Thanks for the great post..waiting for your next post....
ReplyDeleteIs there any tools available for Javascript optimization?
ReplyDeleteHi,
ReplyDeleteI have read your many posts and found all interesting and helpful. Thanks for this awesome article.
Regards
SEO Boston
This is a really good read for me. Must agree that you are one of the coolest blogger I ever saw. Thanks for posting this useful information. This was just what I was on looking for. I'll come back to this blog for sure! I bookmarked this blog a while ago because of the useful content and I am never being disappointed. Keep up the good work
ReplyDeleteOnce i started reading this article i could not stop as got a lot of useful info for my future work.
ReplyDeleteI wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post
ReplyDeleteCreating a Javascript object is VERY DIFFERENT from the way it is done in languages like C++ or Java. This very approachable introductory tutorial illustrates the very dynamic - and startling to the uninitiated - syntax for creating Javascript objects. A MUST READ to avoid confusion.Thanks.:)
ReplyDeleteThanks for the information provided by you is so useful and very informative for Javascript optimization.
ReplyDeleteI learn a lot from this post. Its so amazing post. There are multiple costs to non-compliance, including financial, both personal and societal, and physical.
ReplyDeleteThis was such an interesting article, great read.
ReplyDeleteVery informative thanks for sharing.
ReplyDeleteThe ideas are fantastic and the key things you said in truth,many comments are right and I think you should be better,and good luck in your life.
ReplyDeleteI am extremely pleased for this great read, I definitely enjoying every thought.
ReplyDeleteThanks for taking the time to discuss this, I feel strongly about it and love learning more on this subject.
ReplyDelete