X
X
xelat2014-07-20 07:07:51
JavaScript
xelat, 2014-07-20 07:07:51

How to organize client js code?

There is a working web-project. Js code lies in several files that contain functions. The logic is spread over html templates. Decided to clean up. First of all, take out all the js code in files, wrap everything in modules. Which is exactly what was done. There is a desire to collect all modules-files into one, maximum two files, for connection on the site.
The question is how to properly organize the execution of logic. Generate for each page, section of the site, its own js file, which contains all the js initialization code for the necessary modules. Or make one file in which to write a handler that will initialize modules based on the specified conditions.
I hope I didn't explain too confusingly.
Thanks for the help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xelat, 2014-07-21
@xelat

Thanks for answers.
But I have a logical block. There is an understanding of how to write an application with a single entry point on the same backbone, I mean that there is an index.html in which myApp is initialized. But in my case, there is a working classic web project, where there are different pages on which you need to execute your js. And here is a stupor, how to optimally organize, convenient work with js.

N
Nevelon, 2014-07-21
@Nevelon

If broken into modules, it is convenient to use requirejs . What does he give? Only the required modules are dynamically loaded. Uploaded files are cached. Easy to manage dependencies

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question