Sorry for posting this but !function is not google-able and I did not find it in my JavaScript code.
Here is how Twitter uses it:
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://google.com" data-text="Google says">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
It is short-hand or alternative of self-invoking anonymous function:
Can be written:
You can also use
+instead of!.If you simply did:
That will create problems, that’s why you need to add
!before it which turns the function declaration into function expression.Quoting docs, section 12.4:
To better understand the concept, you should check out: