O
O
Oleg Drapeza2016-05-17 17:08:19
JavaScript
Oleg Drapeza, 2016-05-17 17:08:19

How to optimize a project on require.js?

Good afternoon!
I am working on an old and fairly large project, about 500 scripts, everything is loaded via require.js separately, so the site loading time is extremely inappropriate.
When loading, almost all scripts are connected, so I want to have one js file, without duplicates and other garbage.
There is no clear start module, the require script, its config and the first main.js script are included in the html page:

script.setAttribute("data-main", "/require-config.js?c=" + Date.now().toString());
script.onreadystatechange = script.onload = function (){
    ...
    script.setAttribute("src", "main.js");
    ...
}
script.setAttribute("src", "/lib/requirejs/require.js");

How to optimize the require.js application, collect all the scripts (which are included when the site loads) into one file, and not lose the asynchronous loading of other files?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2016-05-17
@bromzh

webpack + async-loader for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question