Valid Google +1 xhtml code that doesn´t slow page load speed
October 21, 2011 Social Networks
You probably by now have heard the term “+ one” or “Google + 1” lately. Google is redefining the meaning of “plus one” as plus one now means this website, page, article, information is important. Plus one is Google’s answer to the “Like” button or Twitter’s “Follow” button and it will basically count as an ‘up’ vote.
Google give two code alternatives that can be used to place the buttons on pages. Unfortunately, one is not valid HTML or XHTML at all, and the other is only valid for people using the experimental HTML5. The other issue is that you need to include a javascript from Google’s server, and some are reporting that this slows their page load speed significantly.
So to take the plus one button from Google to the next step and make the code xhtml compliant, you have to replace the following:
<g:plusone></g:plusone>
With this next line. Please note that the html id value can actually be whatever you want.
<div id="plusone"></div>
Then place the link to Google’s Javascript right at the end of your page, just before the body tag ends:
<script type="text/javascript"
src="https://apis.google.com/js/plusone.js">
{"lang": "en-GB", "parsetags": "explicit"}
</script>
After calling the Google plus one API you will nead to call some javascript to insert the button in place.
<script type="text/javascript">
gapi.plusone.render("plusone",
{"size": "standard", "count": "true" });
</script>
Note that the “plusone” used here is the same “plusone” id we used in the div. The rest of the attributes: size and count, are just used for styling purposes.
If you like, you can go even further an place a div around the button div itself and set the size of the button. This is used so that the place for the div to be hold in your template be before the button loads. So the code of your div for the valid plus one button will be like this>
<div id="plus"><div id="plusone"></div></div>
If you chose to use this additional div, yo will also have to insert a small line in your .css file to set the width and height of your second div.
#plus { width: 106; height: 24; }
Conclusion
Using this code instead of the normal Google +1 code will not boost your site loading speed, but will maintain it exactly the same as the +1 button will be load after your theme and content is loaded.
No related posts.
2 Responses to “Valid Google +1 xhtml code that doesn´t slow page load speed”
Leave a Reply Cancel reply
-
Recent Posts
- Cool animation effect using pure CSS transitions and some more CSS3 properties
- Kindle fire vs iPad – Did I mention that Kindle Fire costs 199$
- Are You Ready for HTML 5?
- Restrict file download in Google Docs
- 20+ useful Apps for Android, get the best of your device using Android Apps
- Google+ Pages on Google Search with Google Direct Connect
- Valid Google +1 xhtml code that doesn´t slow page load speed
- India launches Aakash, a cheap tablet for only $35
- 2.0 Websites – design ideas using HTML5
- Hangouts, the free multi conference call service by Google plus
- Display your latest Google+ update on WordPress
- Prefetching images and links with HTML5
- CSS3 @font-face solucions. Typekit vs Google Web Fonts
- What is SSL certificate? Secure your data
- POP vs IMAP vs SMTP vs Forwarding emails
- Pure CSS3 and HTML web form design
- HTTP vs HTTPS, What’s the difference
- Google documents adds Comment-only access and colaboration
- What is Google Adsence Premium Publisher
- Differences between VPS and Dedicated Server
Categories
Email newsletter
Subscribe your emailArchives
Labels
2.0 Web Aakash Amazon Android Apple Browsers CSS3 Dedicated server Email Email forwarding Fonts Gmail Google+ Google Adsense Google API Google Calendar Google Docs Google Tasks Google Web Fonts Hosting htaccess HTML HTML5 htpasswd IMAP ipad kindle Fire Mobile Apps Offline Apps Password protect POP Prefetching Security SMTP SSL certificate Tablet Terminology URL video conferencing Website
2.0WebTutorials
Um… maybe convert back to html instead of using encoded special chars…
Chris
Ok done, Thank you Chris