I can see a lot of issues with this (slow, displaying different content to Google can get you penalized, etc)... but this is a really clever hack.
Google is less important (they already execute JS), however it's good for sites like Facebook (which doesn't when you share a link).