git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 26, 2011, 11:08 UTC
Message-ID
<201103261208.44548.jnareb@gmail.com>
In-Reply-To
<4D8D112A.5020703@eaglescrag.net>
On Fri, 25 Mar 2011, J.H. wrote:
Show 5 quoted lines
> 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
Previous: J.H.
Message 6 of 6 in “gitweb: Split gitweb.js, improve JavaScript”
  1. 0/3 gitweb: Split gitweb.js, improve JavaScriptJakub Narebski, Mar 25, 2011
  2. 1/3 gitweb: Split JavaScript for maintability; concatenate on buildJakub Narebski, Mar 25, 2011
  3. 2/3 gitweb: Update and improve comments in JavaScript filesJakub Narebski, Mar 25, 2011
  4. 3/3 gitweb: Fix parsing of negative fractional timezones in JavaScriptJakub Narebski, Mar 25, 2011
  5. J.H.Mar 25, 2011
  6. Jakub NarebskiMar 26, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.