Why need to use semicolon before defining a function?

This semicolon will help you to properly concatenate a new code into a file when the current existed code in this file does not include a ; at the end.

For example:

(function() {

})()  // <--- No semicolon

//  Added semicolon to prevent unexpected laziness result from previous code    
;(function ($) {

})();

Without the semicolon, the second () would have been interpreted as a function call, and will tried to call the return result of the first function


This is just to make sure to terminate any previous instruction.

the semi colon before function invocation is a safety net against concatenated scripts and/or other plugins which may not be closed properly.

https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/extend.html