Closed Bug 553687 Opened 14 years ago Closed 14 years ago

Lazy load JavaScript Modules

Categories

(Firefox for Android Graveyard :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mfinkle, Assigned: mfinkle)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
We Cu.import any needed JavaScript modules. We could lazy load those modules when they are needed. This can help our startup time.

This patch: 
* Lazy loads some modules
* Removes unused SpatialNavigation

Even though we have spatial nav turned off, the callback method is broken if someone _did_ try to turn it back on.
Attachment #433628 - Flags: review?(21)
Comment on attachment 433628 [details] [diff] [review]
patch

>-Cu.import("resource://gre/modules/SpatialNavigation.js");
>-Cu.import("resource://gre/modules/PluralForm.jsm");
>+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
>+
>+XPCOMUtils.defineLazyGetter(this, "PluralForm", function() {
>+  Cu.import("resource://gre/modules/PluralForm.jsm");
>+  return PluralForm;
>+});

Do we really need to have these import both in browser-ui.js and browser.js?


Also we're still setting pref("snav.enabled", false); in app/mobile.js.
Looking at mxr I can't find it defined to true all.js, so I bet we can just remove this pref and everything should works fine. (Spatial Navigation is defaulting to false if the pref is not found: http://mxr.mozilla.org/mozilla-central/source/toolkit/spatial-navigation/SpatialNavigation.js#486)
(In reply to comment #1)
> (From update of attachment 433628 [details] [diff] [review])

> >+XPCOMUtils.defineLazyGetter(this, "PluralForm", function() {
> >+  Cu.import("resource://gre/modules/PluralForm.jsm");
> >+  return PluralForm;
> >+});
> 
> Do we really need to have these import both in browser-ui.js and browser.js?


Nope. I'll remove the one from browser.js since it will have no need for any imported modules.

> Also we're still setting pref("snav.enabled", false); in app/mobile.js.
> Looking at mxr I can't find it defined to true all.js, so I bet we can just
> remove this pref and everything should works fine. (Spatial Navigation is
> defaulting to false if the pref is not found:
> http://mxr.mozilla.org/mozilla-central/source/toolkit/spatial-navigation/SpatialNavigation.js#486)

I'll remove the pref from mobile.js

I really don't want any Spatial Nav code at all. Even initializing the code hooks up a key event handler, which slows the code down for no good reason.

http://mxr.mozilla.org/mozilla-central/source/toolkit/spatial-navigation/SpatialNavigation.js#58

r+ with those changes?
> I really don't want any Spatial Nav code at all. Even initializing the code
> hooks up a key event handler, which slows the code down for no good reason.
> 
> http://mxr.mozilla.org/mozilla-central/source/toolkit/spatial-navigation/SpatialNavigation.js#58
> 
> r+ with those changes?

Sure.

Sorry for the late response, I've not seen your reply because I wasn't CC'ed on this bug.
Attached patch patch 2Splinter Review
with review changes
Assignee: nobody → mark.finkle
Attachment #433628 - Attachment is obsolete: true
Attachment #433915 - Flags: review?(21)
Attachment #433628 - Flags: review?(21)
pushed:
http://hg.mozilla.org/mobile-browser/rev/fdb9b8bce411
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: