What does the leading semicolon in JavaScript libraries do?
javascript, syntax
Solution
It allows you to safely concatenate several JavaScript files into one, to serve it quicker as one HTTP request.
Problem
In several JavaScript libraries I saw this notation at the very beginning: ``` /** * Library XYZ */ ;(function () { // ... and so on ``` While I'm perfectly comfortable with the "immediately executed function" syntax ``` (function(){...})() ``` I was wondering what the leading semicolon is for. All I could come up with is that it is an insurance. That is, if the library is embedded in other, buggy code, it serves as an "the last statement ends here at the latest" kind of speed bump. Has it got any other functionality?