Search This Blog

In my daily life as a programmer I come across problems. This blog, is where I record them (and more importantly their solutions) so that I can dig them out in the future. I hope it might save others some problem solving time too.

Posts

It is becoming common practice to concatenate javascript files. Such concatenation means that only one HTTP request is required to download the necessary javascript rather than several. This reduction in HTTP overhead reduces the time taken to download the particular web application. This concatenation can introduce an unforeseen problem: if, in one file, some code is not properly finished (i.e. with a semicolon), and the proceeding file begins with a closurebeing opened, the interpreter will break.

Jquery plugins often begin with closures and so are susceptible to this problem. Beginning the file with a semicolon will prevent this kind of problem. Where a file begins with a closure, best practice should dictate that it begins with a semicolon. An example of this practice in action is source code of the jquery form plugin.