kiwix-js icon indicating copy to clipboard operation
kiwix-js copied to clipboard

Refactor app.js to reduce its size/complexity

Open mossroy opened this issue 5 years ago • 3 comments

The file app.js now has around 1400 lines. It's way too much IMHO. We should find a way to reduce its size and complexity, so that newcomers can get into it more easily. It would also be easier for us to find what we're looking for.

One approach would be to split it in different .js files. For example, we might move some functions that are specific to one mode (jQuery or SW) in a specific file for each mode. But it's just an idea.

It might be not so easy because of some global variables that we use in app.js, that would not be accessible from other files. Maybe passing them as parameters could be enough in most cases (if the functions do not modify them)

mossroy avatar Jun 01 '19 12:06 mossroy

Good idea. It may be worth pointing out that any variables set in init.js become global to the whole app. It is suitable, for example, for setting global parameters retrieved from cookies, e.g. a global params object.

Jaifroid avatar Jun 01 '19 13:06 Jaifroid

Can I try refactoring this?

ykabusalah avatar Mar 24 '20 22:03 ykabusalah

@ykabusalah Unless you're familiar with the codebase, I would suggest that this is quite a complex task and not a good first issue.

Jaifroid avatar Mar 25 '20 06:03 Jaifroid