<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>TLS Web Solutions &#187; google api</title> <atom:link href="http://www.tlswebsolutions.com/tag/google-api/feed/" rel="self" type="application/rss+xml" /><link>http://www.tlswebsolutions.com</link> <description></description> <lastBuildDate>Thu, 02 Jun 2011 20:41:14 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.3</generator> <item><title>Google AJAX API and jQuery integration, bandwidth free!</title><link>http://www.tlswebsolutions.com/google-ajax-api-and-jquery-integration-bandwidth-free/</link> <comments>http://www.tlswebsolutions.com/google-ajax-api-and-jquery-integration-bandwidth-free/#comments</comments> <pubDate>Sat, 22 Aug 2009 19:45:29 +0000</pubDate> <dc:creator>Tim Selaty</dc:creator> <category><![CDATA[Google]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[XHTML]]></category> <category><![CDATA[google ajax]]></category> <category><![CDATA[google ajax api]]></category> <category><![CDATA[google and jquery]]></category> <category><![CDATA[google api]]></category> <category><![CDATA[google.load()]]></category> <category><![CDATA[jquery bandwidth]]></category> <category><![CDATA[jquery integration]]></category><guid isPermaLink="false">http://www.tlswebsolutions.com/?p=222</guid> <description><![CDATA[As we all know Google has released some pretty nifty things in the past. Today, we&#8217;re going to [...]]]></description> <content:encoded><![CDATA[<p>As we all know Google has released some pretty nifty things in the past. Today, we&#8217;re going to look at one of its most delightful additions for web developers. Google AJAX API.</p><h3>What is Google AJAX API?</h3><p>Google&#8217;s AJAX APIs let you implement rich, dynamic web sites entirely in JavaScript and HTML. You can add a map to your site, a dynamic search box, or download feeds with just a few lines of JavaScript.<span id="more-222"></span></p><p>In human terms, it loads common JavaScript frameworks such as MooTools, jQuery, Prototype, jQuery UI and of course even Google Maps without having to have the (.js) files on your server.</p><h3>That&#8217;s great, but what does that mean for me?</h3><p>Bandwidth, bandwidth, bandwidth, cache headers, and bandwidth.</p><p>Because jQuery, like images, must be downloaded onto the users computer before it can be used. If you have a slow server this can be a painful process especially if you use multiple JavaScript libraries.</p><p>Google is lightning fast, always. To have one, maybe two less items to download from your server not only saves bandwidth, but it saves you time. You don&#8217;t have to go to jQuery and download the latest version, upload it to your server, and type in the path to the (.js) file. You also don&#8217;t have to worry about having relative or absolute URLs due because of pretty URLs (seo friendly URLs).</p><p>You just add a two lines of code to the head of your template, sometimes even one, and you&#8217;re done. Google automatically sends a request to their server to download all of the JavaScript you&#8217;re requesting, cache the headers, and return it back to you.</p><p>Even better yet, the code is cleaner. You only need one line of code to load in multiple JavaScript libraries instead of your usual 3-5 lines of code.</p><h3>Enough already, just show me how</h3><p>Glad you asked. Below is the example XHTML page used to load in jQuery and execute a test function to ensure that it works.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;color: #003d68;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">src</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;http://www.google.com/jsapi&quot;</span>&gt;&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">type</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;text/javascript&quot;</span>&gt;</span>google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">type</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;text/javascript&quot;</span>&gt;</span>$(document).ready(function(){$(&quot;.expanded&quot;).hide();$(&quot;a&quot;).click(function(){$(&quot;.expanded&quot;).fadeIn(600);});})<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">p</span> <span style="color: #000066;color: #FF0000;">class</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;expanded&quot;</span>&gt;</span>Who uses paragraphs anymore?<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">p</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">a</span> <span style="color: #000066;color: #FF0000;">href</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;#&quot;</span>&gt;</span>Expand!?<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">a</span>&gt;</span></pre></div></div><p>Now, we&#8217;ve loaded in jQuery and are able to get cracking away. However, what if we want to add more than one library? Simple. All we do is add another instance of google.load();. Below is an example with both jQuery and jQuery UI.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;color: #003d68;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">type</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;text/javascript&quot;</span>&gt;</span>
google.load(&quot;jquery&quot;, &quot;1.3.2&quot;);
google.load(&quot;jqueryui&quot;, &quot;1.7.2&quot;);
<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span></pre></div></div><p>Want to use the latest version of jQuery so you never have to update the code to match the latest version? No problem use this instead.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;color: #003d68;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">type</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;text/javascript&quot;</span>&gt;</span>google.load(&quot;jquery&quot;, &quot;1.3&quot;);<span style="color: #009900;">&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span></pre></div></div><p>What this says is: &#8220;Find the latest stable release that starts with 1.3.x&#8221;. In our case it automatically found v1.3.2.</p><p>Pretty nifty eh? What&#8217;s even better is that jQuery THEMSELVES are using Google&#8217;s server to call their own JavaScript library. If you view the source code of http://www.jquery.com/ you&#8217;ll see on Line 9 the following code.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;color: #003d68;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;color: #000080;">script</span> <span style="color: #000066;color: #FF0000;">src</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js&quot;</span> <span style="color: #000066;color: #FF0000;">type</span><span style="color: #66cc66;color: #000080;">=</span><span style="color: #ff0000;color: #000080;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;color: #000080;">/</span><span style="color: #000000; font-weight: bold;color: #000080;">script</span>&gt;</span></pre></div></div><p>This is also another way of calling jQuery from Google&#8217;s servers.</p><p>That&#8217;s it! Enjoy one less heavy server request.</p> ]]></content:encoded> <wfw:commentRss>http://www.tlswebsolutions.com/google-ajax-api-and-jquery-integration-bandwidth-free/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic

Served from: www.tlswebsolutions.com @ 2012-02-09 10:46:27 -->
