G+ and Facebook Like buttons vs. W3C validation

In the construction of websites is important to respect the standards dictated by the W3C HTML: This website, for example, is built according to the HTML5 standard and faithfully respects the rules with W3C standards, allows you to have a website that is usable in all situations: for example, makes it suitable also for blind people, can be viewed on different browsers or on different platforms (PC, PDA, SmartPhone …) .SEO side, there is evidence that a web page that meets the standard is able to obtain a better ranking than a page that does not respect them: let us be clear, the spiders of the search engines do not perform any control, but compliance with the standards allows the spiders “better understand” the content of the page. For example, a picture without the “alt” attribute, in addition to not meet the standards, it is incomprehensible to a search engine.

In the control phase of the site, I ran into a problem with no immediate solution: to make the site “social”, each post comes with the buttons to report it to the most common social networks: Twitter, Facebook, Linkedin and Google+.
Buttons for Facebook and Google+, however, use a syntax that is not compatible with the W3C standard. For example, the code for Google+ “standard” is:

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone size="medium" href="http://www.azns.it"></g:plusone>

While the code for the “Like” button of Facebook:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="" layout="button_count" send="true" show_faces="false" width="450" font=""></fb:like>

The problem is in the tag g: pluszone and fb: like that are not recognized by the W3C standards, but they are necessary to bring up the buttons: how to pass validation?
The trick is quite simple: use JavaScript to ask your browser to enter the Google+ and Facebook code, without plugging it directly into the page. This implies a slight slowdown because your browser must execute the statement, but the page exceeds smoothly the W3C validator control.
This is the new code:

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript">
  document.write('<g:plusone size="medium" href="http://www.azns.it"></g:plusone>');
  document.write('<fb:like href="" layout="button_count" send="true" show_faces="false" width="450" font=""></fb:like>');