Modifying Chow-Down Part 2: Make it Faster!
April 21st, 2009 | Published in Youtube API
As promised in the previous blog post, I was given the task of making our Chow Down Gdata sample a little faster. It would sometimes take a while to load restaurant information due to the requests to YouTube and Picasa Web Albums taking a while to be processed on the backend. Since this would cause the user to sometimes see a "loading" bar for several seconds; something had to be done.
Originally, the application used the Python client library to retrieve information from YouTube and PWA and then stored it inside of memcache. The new solution is to instead retrieves these feeds directly in the browser using the json-in-script support of the Google Data APIs. This approach worked well for the Chow Down application since we were not retrieving any private information for use in this application and so did not need to authenticate as a user.
Another benefit of using the JSON feeds is that the browser can asynchronously request results from both YouTube and PWA at the same time and render the results as soon as they are returned. This helps decrease the "perceived load time" that the user experiences since they are seeing information start to be loaded instead of just watching a progress bar.
The code for the entire sample is available on code.google.com:
http://code.google.com/p/gdata-samples/source/browse/trunk/chow-down-gdata/
But you can see all of the logic for retrieving the feeds using JavaScript in the ajax_restaurant_info template:
http://code.google.com/p/gdata-samples/source/browse/trunk/chow-down-gdata/src/templates/ajax_restaurant_info.html
The code makes use of the jQuery JavaScript library in order to remain compact and compatible.
So if your site is using the Data APIs of one or more Google properties and you don't need authentication, considering switching to the JSON feeds to improve perceived latency and let your pages load the AJAXy way.
Originally, the application used the Python client library to retrieve information from YouTube and PWA and then stored it inside of memcache. The new solution is to instead retrieves these feeds directly in the browser using the json-in-script support of the Google Data APIs. This approach worked well for the Chow Down application since we were not retrieving any private information for use in this application and so did not need to authenticate as a user.
Another benefit of using the JSON feeds is that the browser can asynchronously request results from both YouTube and PWA at the same time and render the results as soon as they are returned. This helps decrease the "perceived load time" that the user experiences since they are seeing information start to be loaded instead of just watching a progress bar.
The code for the entire sample is available on code.google.com:
http://code.google.com/p/gdata-samples/source/browse/trunk/chow-down-gdata/
But you can see all of the logic for retrieving the feeds using JavaScript in the ajax_restaurant_info template:
http://code.google.com/p/gdata-samples/source/browse/trunk/chow-down-gdata/src/templates/ajax_restaurant_info.html
The code makes use of the jQuery JavaScript library in order to remain compact and compatible.
So if your site is using the Data APIs of one or more Google properties and you don't need authentication, considering switching to the JSON feeds to improve perceived latency and let your pages load the AJAXy way.