I was reading through my javascript file, and two questions came to my mind:
1) i have 26 strings of text that i use, and some of them gets repeated in several functions.
So i thought if would be a good idea to declare all them as global vars?
2) 95% of my code is javascript, the rest is JQuery. The logics are very simple. Is it worth converting all my JS code to JQuery?
Sample code:
email = document.getElementById('email').value;
document.myForm.submit();
It is usually a good idea to group the constant variables in a single spot, so they are defined only once, without duplication, and are easy to look at and modify.
However, I would prefer to group the dictionary into a single object or module. This would reduce clutter on the global namespace, would indicate the variables are connected and would allow you to iterate and manipulate them better (if you wish to do so). It is the same reasoning behind using arrays instead of having x1, x2, …, xn variables.
Also, jQuery is just a Javascript library. I don’t really see a reason to try to convert the code (and risk accidentaly breaking it), given the info you gave us.