The first trick is interesting. It looks like a creative way to pass "global" arguments from the page markup to external scripts. There are ways to find the <script>
element that sources the code that's currently running, and I would not be surprised if the inner text of that <script>
element was accessible from the DOM even though the browser ignores it.
In your question, this pattern allows each external client-side script to use (at least) its own localization settings, and also allows server-side code to render that parameter as a side effect of rendering the <script>
element itself. That's impressive.
The second trick, I'm not so sure about. Basically, I think most browsers would consider the namespaced <g:plusone>
element as unknown or even invalid, so they should render its content, but it won't do anything, of course, since that element is empty to begin with.
However, client-side code might still be able to match the namespaced element using DOM navigation, and replace it with its own generated content.
xmlns:g
is never specified. – Quaquaversal