I have recently noticed that a lot of JavaScript files on the Web start with a ;
immediately following the comment section.
For example, this jQuery plugin's code starts with:
/**
* jQuery.ScrollTo
* Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 9/11/2008
.... skipping several lines for brevity...
*
* @desc Scroll on both axes, to different values
* @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
*/
;(function( $ ){
Why does the file need to start with a ;
? I see this convention in server-side JavaScript files as well.
What are the advantages and disadvantages of doing this?
return
statement as the last thing in a script, can you? Returning at top level doesn't make sense. It'd have to be something else, right? – Outrageous