I have index page with a container to which I load content obtained with ajax requests. These subpages can contain js specific especially to them that needs to be loaded only once. I would like to achieve the following:
If the subpage is loaded for the first time it loads the javascript, but if it is the second or n'th time, then javascript should not be loaded (because it is already in memory).
I could achieve that with some variable and checking its value before executing, but I am asking here if there is a proper, tested and used-by-many way of doing that. I am using MVC3 and jQuery if that's important.