Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

added 10 characters in body
Source Link
levik
  • 118.1k
  • 28
  • 77
  • 92

For really JS-heavy applications, you should try to mimic Java.

  • Have as little JS in your HTML as possible (preferably - just the call to the bootstrap function)
  • Break the code into logical units, keep them all in separate files
  • Use a script to concatenate/minify the files into a single bundle which you will serve as part of your app
  • Use JS namespaces to avoid cluttering up the global namespace:

var myapp = {};
myapp.FirstClass = function() { ... }; 
myapp.FirstClass.prototype.method = function() { ... }; 
myapp.SecondClass = function() { ... }; 

Using all these techniques together will yield a very manageable project, even if you are not using any frameworks.

For really JS-heavy applications, you should try to mimic Java.

  • Have as little JS in your HTML as possible (preferably - just the call to the bootstrap function)
  • Break the code into logical units, keep them all in separate files
  • Use a script to concatenate/minify the files into a single bundle which you will serve as part of your app
  • Use JS namespaces to avoid cluttering up the global namespace:
var myapp = {};
myapp.FirstClass = function() { ... }
myapp.FirstClass.prototype.method = function() { ... }
myapp.SecondClass = function() { ... }

Using all these techniques together will yield a very manageable project, even if you are not using any frameworks.

For really JS-heavy applications, you should try to mimic Java.

  • Have as little JS in your HTML as possible (preferably - just the call to the bootstrap function)
  • Break the code into logical units, keep them all in separate files
  • Use a script to concatenate/minify the files into a single bundle which you will serve as part of your app
  • Use JS namespaces to avoid cluttering up the global namespace:

var myapp = {};
myapp.FirstClass = function() { ... }; 
myapp.FirstClass.prototype.method = function() { ... }; 
myapp.SecondClass = function() { ... }; 

Using all these techniques together will yield a very manageable project, even if you are not using any frameworks.

Source Link
levik
  • 118.1k
  • 28
  • 77
  • 92

For really JS-heavy applications, you should try to mimic Java.

  • Have as little JS in your HTML as possible (preferably - just the call to the bootstrap function)
  • Break the code into logical units, keep them all in separate files
  • Use a script to concatenate/minify the files into a single bundle which you will serve as part of your app
  • Use JS namespaces to avoid cluttering up the global namespace:
var myapp = {};
myapp.FirstClass = function() { ... }
myapp.FirstClass.prototype.method = function() { ... }
myapp.SecondClass = function() { ... }

Using all these techniques together will yield a very manageable project, even if you are not using any frameworks.

lang-js

AltStyle によって変換されたページ (->オリジナル) /