To Async or Not To Async… That is the ReWritten Cliche Quote.

One of the things I’ve been wondering as a of late, besides why Micheal Bay still is allowed to make movies… and no money is NOT and excuse, is whether it’s better to just load and entire page and hide/show stuff on some click OR only load what’s shown and have said click handle loading the stuff through Asynchronous Calls and Json.

I bet that made sense!

Here’s the situation, I have a blog thing I’m working on and it allows for multiple blogs per site. The “splash” page, if you will, looks like this:

BAT_BlogSplash1

And when you click “Newest” it looks like this:

BAT_BlogSplash2

As you can see, Newest brings up a pop out div thing that shows the latest post.

Side note, I was going to have it just show the first X characters of the post as a teaser, but turns out that if there is any broken HTML because of that, IT’S A HUGE PAIN TO FIX. Something like <div> this is something that <di… OH SNAP THE DIV IS BROKEN! ALERT! ALERT! So this was a “solution”.

Originally I had it loading the needed post in it’s respective pop out div and just hiding all of them. Then it would show the post when the Newest “button” was clicked. Then it dawned on me that this might be silly since only one is going to be open at a time. Why send the client a ton of unneeded html? So, I moved on to using jQuery/Json to grab the needed post data when the Newest “button” is clicked. Then I just populate the pop out div with the returned information as it opens… or whenever it gets back to the client. Can’t always assume it will be there immediately. Interweb can be slow at times.

Anyways, this brings up an issue: Am I better off with the first or second solution? Given that all things are equal, it seems like a better idea to have the jQuery solution due to the fact you aren’t sending useless html to the client. This will most definitely help with initial load time for the client. Only problem is, that jQuery method is run every time one of the Newest “buttons” is pressed meaning you could have an infinite amount of requests per person. I suppose this is a matter of gambling really.

Do I go with full html and because I assume the user will look at all the latest posts anyhow and therefore cut down the needed requests?

Do I go with the jQuery method because more often than not, users will not look at all the latest posts OR at least will take some time in between the Newest “button” pressing so that it’s ok there might be a ton of requests over time?

At this point I think the second is the way to go, but it’s most likely situational. Time will tell.