Re: [PATCH/RFC 0/3] gitweb: Split gitweb.js, improve JavaScript

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 Mar 2011, J.H. wrote:

> The only thing I would comment on is that we may want to document (for
> the build process) a way to force a certain ordering of various files.
> Case in point we probably want to force the things like various global
> defs (what I'm proposing in the timezone stuff) at the top and let the
> function defs go below that.
 
Actually I don't think that matters, at least not if JavaScript files
contain only variables and functions, and do not include any code that
is actually run when file is loaded.  A very simple test (below) 
confirms that.

In JavaScript variable declarations ('var' keyword) and function 
definitions ('function' keyword) get "hoisted" at beginning.  

> Other than that this all looks good.

Thanks.
 
-- 8< --
<html>
<head>
<title>JavaScript test</title>
<script>
// -------------------------------------------
// B

var varB = 'varB';

function fooB() {
  fooA();
  alert('varB='+varB + '; varA='+varA);
  return 'fooB';
}


// -------------------------------------------
// A

var varA = 'varA';

function fooA() {
  alert('varA='+varA);
  return 'fooA';
}


// ===========================================
// main
fooB();
</script>
</head>
<body>
test
</body>
</html>
-- >8 --
-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]