I'm working on an AJAX based application that is dynamically loading in resources (external CSS/JS files) based on the page/area that is being loaded into the interface. This works fine however I want to make sure that the external files (which are loaded in simply by doing a $('head').append() of the necessary link and script tags) are finished loading BEFORE the actual page that requires them is accessed.
I thought that I would be able to bind a $(window).load() event which would fire after the external files are finished loading, and the callback would initiate the request for the actual page content. However, it looks from initial tests that the event is not being fired. I also made sure its not due to the file being loaded from my cache as I cleared my browser cache prior to the test.
Can anyone see any reason why this would happen? Or am i going about this in completely the wrong way?