If there is too much content, preloading it will be very slow for end users. I suggest you move on to the second approach to dynamically request content when you click a link.
You can easily simplify the design by capturing all the links and making an ajax call to retrieve the content and paste it into the appropriate container. Assuming each link retrieves content from a different URL, and that content is pasted into a different container depending on which link was clicked, you just need to assign several attributes to each such AJAX'd link:
Define a data-remote attribute for each link that can download content using AJAX.
Define another data-container attribute that indicates the identifier of the container into which the result should be inserted.
// this is the ajaxy link <a id="test" data-remote="true" data-container="container-id" href="..">Load</a>
Finally, apply the click handler to all links that have the data-remote attribute:
$('a[data-remote]').click(function() { var containerId = this.attr('data-container'); var url = this.attr('href'); $('#' + containerId).load(url); return false;
source share