Can you tell us why you want to put different page codes in one file, given the fact that you are 100% sure that these codes will not be executed, in fact you spend time creating code / controller to avoid execution this unrelated code.
Also, how many pages you say, if it's only 2 pages, then you should be fine. But what if 50 pages? What if 20 pages use the same code that your controller will look like? Or are you going to copy the same code 20 times?
HOWEVER, having all the codes in a minified single file seems to load faster than the browser initiating multiple downloads. You must have a balance between VS VS coding practice.
I tend to have different js files with special code for different pages, so unrelated codes do not load.
Any common code, I put it in specific js lib files, so most of the unrelated lib code doesn't load.
Eg.
Search page will have: search_page.js util.js form_validation.js Result page will have result_page.js util.js lib_map.js
Just my $ 0.02
James Lin Dec 07 '10 at 1:24 2010-12-07 01:24
source share