I want my JS to load certain information that needs to come from the server. Examples would be URLs, language specific messages, etc. What is the best way to get this information from the server to the JS?
Right now, I have such values stored in an actual JS file. I don't like this approach because information is duplicated on the server side.
Would it be a good idea to have an initial JS to make an Ajax request to get all these details? Perhaps store this in a global variable so that it is accessible from anywhere? (A benefit of my current approach is that I don't need to necessarily set such information as a global variable; I could, for example, hard code and alert message where it is needed).
Any advice on best practice for my situation?