Creating an object with all the methods you need is a very good idea. It’s called creating a name space. This avoids conflicts in the case of declaring variables or functions with names that may already exist.
Regarding merging several codes in the same file depends a little. If the overall script is not too large it is good to have it in the same file to have everything organized.
If it is large it may be better from a performance point of view to have several parallel requests running simultaneously, this makes the page load faster despite being multiple requests.
The code that doesn’t need to be on <head>
(code that is not needed before the user interacts) can load after (outside the head) and this also makes the page load faster.
Helder, this code is really big. I want to help but I’m not going to look at all this code, I don’t have time. You can clarify the question and add a schematic of the code?
– Sergio
My question is whether, define this object "Ecommerce" and assign all the functionalities to it is correct to do. The other item refers to plugins that are loaded at the end of the file, it would be better to create a "plugins.js" for example, instead of loading them in the same file? In performance issue, it would be better 1 file only right, because it is a request less.
– helderburato