Organization of a project based on a JavaScript library

I am very new to the JavaScript library world. I myself used JS to create a mini social network, but this is the first time I use the JS library, and I really don't know how to do it.

I plan on using Google Closure, and I'm really not sure how I should organize the code. Should I put everything in one file from a web application and should have one screen? Should I separate the code from many fragments and put them in different files? Or should I put different dialogs (for example, settings) on a separate page and, therefore, a separate file?

Like all programmers, I am a perfectionist, so please help me with this, thanks.

+3
source share
2 answers

If you use Closure, you can use the closure compiler. I would recommend several js files that are compiled into a single resource by the compiler. You would specify this single js file in your html, so you would not need to reference all of them.

Then, since you have several JS files, you can organize them logically, which will help you separate the logic from the user interface from communications, etc. In addition, if you write unit tests (JsUnit), it will be easier to write one test file in the js file.

+2
source

... , , - ( ), , , . 20 script, , , .

+1

Source: https://habr.com/ru/post/1745513/


All Articles