I am working on a system that uses the Leaflet API for creating a map that shows data. I can put a control bar on the map, that allows me to interact with the map. The content of this control bar is HTML. Now, my question:
Should I build the HTML of this control bar in the JavaScript I send to the client, or should I call the control bar with an AJAX call from my ASP.NET controller?
Some pros and cons of each approach:
If I build the control bar in JavaScript, my JS file will become messier, with lots of HTML. Putting the control bar in an ASP.NET page would decouple the HTML and JavaScript, which seems like a positive thing to me. It would save the server one request, as the code to create the control bar is already sent along with the JS files.
Putting it in an ASP.NET page means the JS file is smaller, but the application needs to make an extra call to the server to obtain the control bar. There are no situations where there's no control bar on the map, so the call to the server would always have to be made if I store the HTML in an ASP.NET page.
Has anybody had to deal with this issue in the past, and how did you handle it?