Use AJAX Libraries API to speed up OpenSocial apps
Posted by Shawn Shen, Developer Programs
Do you use popular JavaScript frameworks like Prototype or jQuery in your OpenSocial applications? Do you share the pain your users might feel when they have to download a popular library like prototype.js yet another time even though it’s been already fetched 33 times? Wouldn’t it be nice if you don’t have to worry about gzipping or minifying these libraries and paying to have them cached on some expensive content delivery network in order to speed up your apps?
If your answer to any these questions is “yes,” you are in luck because Google’s AJAX Libraries API precisely addresses these common pain points that many app developers have.
For example, to load Prototype version 1.6.0.2 you would place the following in your HTML:
<script src=”http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js”></script>
Another way to load these libraries is with the Google AJAX API Loader’s google.load() method.
By loading popular JavaScript libraries from Google’s free content delivery network, you get:
- A faster user experience (for those that already have fetched the files)
- Automatic gzipping and minification, so the files themselves are really small
In short, while the AJAX Libraries API is geared toward all web apps using standard JavaScript frameworks, it is particularly handy for OpenSocial apps because they are rendered in iframes, often multiple times (e.g. on user profiles). The steps involved in optimizing your apps can be tricky (See the latency best practices article). By using AJAX Libraries API, app developers can spend more time building out functionality and less time worrying about latency.
(Via OpenSocial API Blog.)
leave a comment