I currently echo certain variables in hidden input fields and read them out with Javascript whenever I need them.
Me and a colleague are now thinking of generating an extra Javascript file with PHP which only contains all variables for Javascript. This way the variables already exist and there is no extra code in the HTML.
What are good ways to pass variables from PHP to Javascript? And how does our solution sound?