Global object for project

3

I'm sure if this mode would be a very "ugly" method to do:

link

In this case, an object called "Ecommerce" has been defined, and I'm giving it the functionality.

Another item that would like to know other ways, or if it is correct, is the loading of plugins in the same file.

    
asked by anonymous 15.08.2014 / 19:15

1 answer

2

Creating an object with all the methods you need is a very good idea. This is called creating a name space . This avoids conflicts if you declare variables or functions with names that may already exist.

Regarding putting multiple codes together in the same file depends a bit. If the total script is not very large it is good to have the same file to have everything organized. If it is large it may be better from a performance standpoint to have multiple parallel requests running concurrently, this makes the page load faster despite several requests.

The code that does not need to be in <head> (code that is not needed before the user interacts) can load later (outside the head) and thus also make the page load faster.

    
15.08.2014 / 20:01