dave
dave

Reputation: 15459

Would it be a good idea to AJAX to load page content?

Basically, lets say for the index.html page of a website, instead of using php to load the middle section( content between header and footer ) of the webpage?

Upvotes: 3

Views: 474

Answers (4)

RSG
RSG

Reputation: 7123

Yes. Many frameworks are moving in this direction, and most consumer sites (Facebook, Twitter) load most of the content after the main page is loaded.

Provided your users have JS enabled browsers, the AJAX load improves user experience by providing a faster response time and a more dynamic interface for the content which is likely to change. If done correctly, it will actually improve the maintainability of your application by carrying data organization and presentation methodologies through your front-end.

If you want to dive all the way in there are good JS frameworks that incorporate this philosophy into your design, Sproutcore and Backbone are both worth looking into.

Edit

I'm building web applications now, so I read questions with that slant. If, as people have pointed out, you're just building brochureware webpages then you won't see a real benefit from AJAX content loads and will hurt your SEO.

Upvotes: 1

Brad
Brad

Reputation: 163272

You may come across a situation that this is good for. For instance, if your "page" is really a rather heavy-weight client-side web application, then perhaps this is the right choice. Generally though, this is a terrible idea.

What harm do you have in generating a page already filled with your content? You avoid compatibility issues, SEO issues, it loads quickly, and that's one less HTTP request to your server. Just because "good JS frameworks that incorporate this philosophy" exists doesn't mean it is the right method for your application.

Each site is different, but the default answer should be certainly not. If the conditions are right, then yes. Base this decision on what is best for your users.

Upvotes: 3

Shad
Shad

Reputation: 15451

If Search Engine Optimization is a concern for the project the answer is NO =)

Search engines generally only fetch the source code for each page.

Upvotes: 0

Dr McKay
Dr McKay

Reputation: 2568

If you assume that each of your visitors has AJAX-enabled browser (by which I mean JS turned on, etc.), then that would be pretty much correct. I'm not sure (source code looks like), but this seems to be the way Facebook loads it's middle section.

Of course you will have to use PHP either, I hope you know.

Upvotes: 0

Related Questions