What is the best way (performance wise) to display all the categories and respective sub categories with images when the page loads so that I may style the content with an UL LI to display inside Mega Menu?

I was thinking to run a query from the control that contains the Mega Menu which should output all the published categories and sub categories within them. But this constantly go back to the server to run the query? Bad for performance!

Then I thought run the query that outputs the data in an XML file on the client machine (obviously it will run the query from the server the first time) but subsequently it will read off the XML file. Then I style the XML data using XSLT within my Mega Menu control.

Please advise? I am using NopCommerce 1.9