Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Browser Source Organization - Include Files

0 views
Skip to first unread message

Ben Goodger

unread,
Mar 9, 2006, 2:52:13 PM3/9/06
to
- Loading fewer files at startup in optimized builds is better
- Having many files is easier for code maintainability and reuse

An idea for one component-per-file browser source organization happiness
(simplified to get the point across):

browser.xul:

#ifdef DEBUG
<script type="application/x-javascript"
src="chrome://browser/content/component1.js"/>
<script type="application/x-javascript"
src="chrome://browser/content/component2.js"/>
#endif

browser.js

#ifndef DEBUG
#include component1.js
#include component2.js
#endif

This means the error line numbers should be fairly predictable for debug
builds (well, easier to compute at least than browser.js is now... the
file is so long and there are so many #ifdefs that the printed number
has no relation at all to reality).

I'm trying an experiment like this now with the charset menu.

-Ben

Axel Hecht

unread,
Mar 10, 2006, 6:10:40 AM3/10/06
to

How does that impact extension development?

As I don't understand fastload cache, should it be able to take that
off? I wonder how much of a perf hit multiple script nodes really are.
It seems like the xul content sink at least tries to load scripts from
fastload first. Not sure how a completely fastloaded xul doc handles this.

Axel

Ben Goodger

unread,
Mar 14, 2006, 12:22:47 PM3/14/06
to Axel Hecht
Axel Hecht wrote:
> How does that impact extension development?

Shouldn't change anything... script still loaded into same scope.

> As I don't understand fastload cache, should it be able to take that
> off? I wonder how much of a perf hit multiple script nodes really are.
> It seems like the xul content sink at least tries to load scripts from
> fastload first. Not sure how a completely fastloaded xul doc handles this.

This may be true, but not sure how this scales over N script files. I
know there was a non-zero improvement when all the individual files were
collapsed initially.

-Ben

Myk Melez

unread,
Mar 15, 2006, 6:58:19 PM3/15/06
to Ben Goodger
Ben Goodger wrote:
> - Loading fewer files at startup in optimized builds is better
> - Having many files is easier for code maintainability and reuse
>
> An idea for one component-per-file browser source organization happiness
> ...

Seems reasonable, although it makes chrome errors in optimized builds
more difficult to trace (but presumably this capability is less
important than maximizing startup time on those builds).

A related problem is that licenses appear in many JS files as
preprocessor directives. When those get stripped out (even in debug
builds), it skews the line numbers by ~50 lines (depending on the number
of contributors).

-myk

Axel Hecht

unread,
Mar 16, 2006, 1:14:03 PM3/16/06
to
Myk Melez wrote:
> Ben Goodger wrote:
>> - Loading fewer files at startup in optimized builds is better
>> - Having many files is easier for code maintainability and reuse
>>
>> An idea for one component-per-file browser source organization happiness
> > ...
>
> Seems reasonable, although it makes chrome errors in optimized builds
> more difficult to trace (but presumably this capability is less
> important than maximizing startup time on those builds).

This aspect is the part that triggered my extension development
question. Once we mangle different files into one, it's hard to find the
code in lxr or the source to find out what one (extension author) is
doing wrong, or even worse, where one should upstream a bug-fix
discovered by the extension.

> A related problem is that licenses appear in many JS files as
> preprocessor directives. When those get stripped out (even in debug
> builds), it skews the line numbers by ~50 lines (depending on the number
> of contributors).

Shouldn't the preprocessor spew out #line directives in js to fix that?

I thought so.

Axel

Myk Melez

unread,
Mar 16, 2006, 4:22:58 PM3/16/06
to Axel Hecht
Axel Hecht wrote:

> Myk Melez wrote:
>> A related problem is that licenses appear in many JS files as
>> preprocessor directives. When those get stripped out (even in debug
>> builds), it skews the line numbers by ~50 lines (depending on the
>> number of contributors).
>
> Shouldn't the preprocessor spew out #line directives in js to fix that?

Indeed it does now do that (last time I checked, it didn't, but I guess
it's been added since then). Perhaps we could adapt this solution to
the component-per-file line number problem by having the preprocessor
also add "file" directives to the combined file in optimized builds.

-myk

0 new messages