Opened on 04/24/2014 at 11:10:56 AM

Last modified on 12/21/2017 at 11:29:03 AM

#378 new change

Don't load JS modules in a fixed order

Reported by: fhd Assignee:
Priority: P4 Milestone:
Module: Libadblockplus Keywords: goodfirstbug
Cc: Blocked By:
Blocking: Platform:
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):



Currently, JS modules are being loaded in the fixed order specified in the convert_js build action. In order for a module A to require module B, B needs to be above A. This needs to be considered in the code, it's quite the leaky abstraction.

What to change

This needs discussion, see below.

Attachments (0)

Change History (4)

comment:1 Changed on 04/24/2014 at 11:11:10 AM by fhd

I'm not sure what our options are. The easiest one is probably to make require asynchronous, but it's also a rather ugly option. What else can we do?

comment:2 Changed on 04/24/2014 at 11:47:58 AM by trev

  • Cc trev added

Currently the code generated for a module looks like this:

require.scopes["..."] = (function()

So the scopes are created immediately, the require() function merely needs to return the right one. Not running the functions should be the simplest option:

require.modules["..."] = function()

The require() function should then return the cached scope if there is one. If there is none it should run the function for a module to get its scope and cache it, at this point the function can be discarded.

This will match the behavior we have in Firefox more closely. However, it will mean that the modules no longer load automatically meaning that we will need the moral equivalent of lib/main.js in Firefox - explicitly load modules that need to run in background but normally aren't used anywhere (that's filterListener, synchronizer and notification for Chrome and libadblockplus).

comment:3 Changed on 04/24/2014 at 12:05:46 PM by trev

  • Keywords goodfirstbug added
  • Priority changed from Unknown to P4
  • Ready set

comment:4 Changed on 12/21/2017 at 11:29:03 AM by fhd

  • Cc trev removed

Add Comment

Modify Ticket

Change Properties
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from (none).
Next status will be 'reviewing'.
Note: See TracTickets for help on using tickets.