I am currently developing a website and am wanting to include the google plus button. My problem however is that the google plus button adds an extra 300kb to the page weight. A lot of this comes from one single file that the http://apis.google.com/js/plusone.js file calls.
I’ve managed to keep the page load time down to a minimum by loading it asynchronously but I would like to know if there’s any way to adapt the code to minimise the page weight?
Here is the code I am using…
<script>
window.___gcfg = {lang: 'en-GB'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<div id="google-plusone">
<g:plusone annotation="none" size="medium"></g:plusone>
</div>
You shouldn’t really worry about it as it doesn’t affect your code startup time. Most users will most likely just have it in cache already and load it from there. Trying to provide your own somehow “minimized” copy is actually counter-productive, because it won’t profit from being cached from visiting other sites.