Exploring Google’s +1 Button, I found two things odd about the code they supply:
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
{lang: 'en-GB'}
</script>
<g:plusone size="tall" href="http://www.google.com"></g:plusone>
So I have two questions:
First: How is Google able to use the text between the script tags?
Second: Is the syntax <g:plusone ... HTML valid? What’s this called?
<script>elements are perfectly visible in the DOM:Google’s sneaky trick is to put content in a
<script>that has an externalsrc. In this case thesrcoverrides the content inside the block and executes the external script instead, but the contents of the<script>element are still readable through the DOM even though they do nothing.No. If they made their own doctype for HTML+plusone it could be valid that, but it doesn’t satisfy validity for HTML, and it isn’t even namespace-well-formed in an XHTML document, unless you add an extra
xmlns:gfor it too.