I have a serious project with big JS file with many functions, and now I have some questions about it.
Of course, I will stick together all my js files and gzip it, but I have a question about functions initialisations. Now I have many, many simple functions, without any classes. I heard that it is better to separate my code into many classes, and I want to do it, and on page generation step mark in my script, which classes I need on specific page. For example, I don't need a WYSIWYG editor at the main page, and so forth, so I will create special var with array of js classes which I need. Is this the best practice? Will clients get performance and memory savings?
Suppose that I have many links with onclick actions. What is better: leave them as
<a href="#" onclick="return smth();">
or rewrite as<a href="javascript:void(0);">
and create jquery .bind in document.ready section? But what if the client wants to click something before the document is ready?After a click on something I must create a div with specific static html. Where is it better to store this content? In some var in my class? Or maybe in some template?