Opened 6 years ago

Last modified 3 years ago

#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.

Change History (4)

comment:1 Changed 6 years ago 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 6 years ago 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 6 years ago by trev

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

comment:4 Changed 3 years ago by fhd

  • Cc trev removed
Note: See TracTickets for help on using tickets.