What does the leading semicolon in JavaScript libraries do?

前端 未结 6 796
囚心锁ツ
囚心锁ツ 2020-11-22 04:05

In several JavaScript libraries I saw this notation at the very beginning:

/**
 * Library XYZ
 */
;(function () {
  // ... and so on

While

6条回答
  •  囚心锁ツ
    2020-11-22 04:34

    It allows you to safely concatenate several JavaScript files into one, to serve it quicker as one HTTP request.

提交回复
热议问题