wildzero
asked on
Code seperation / minify
:-) Afternoon.
I have a javascript file - which has a whole heap of functions for all over my site.
Now some pages only need 1-2 functions, some need 8 functions, so I am thinking about breaking all the js out into the seperate files based on the pages which would so basically i'd have... 8 different js files and then one base js file which has very common js files.
Im just wondering if I gain for having it all in one (1 http request for the js file, instead of base js and then page js).
Hmmm
I have a javascript file - which has a whole heap of functions for all over my site.
Now some pages only need 1-2 functions, some need 8 functions, so I am thinking about breaking all the js out into the seperate files based on the pages which would so basically i'd have... 8 different js files and then one base js file which has very common js files.
Im just wondering if I gain for having it all in one (1 http request for the js file, instead of base js and then page js).
Hmmm
I think it will be good to have all the functions in one js file so that you can include the js file in the pages.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Technicaly you have no gain or no diference betwean one or eight separate js files.
The advantages of one single file are that you have always the overview what functions you globaly have and what side effects could ocur if you add one new function or change one var name. And most important if you have eight files and do testing and have problems with caching in browser or server side, then you get again clear view better with one file. The previous said is only true as long as that one single file size is les then, let say, thousand lines.
The advantages of one single file are that you have always the overview what functions you globaly have and what side effects could ocur if you add one new function or change one var name. And most important if you have eight files and do testing and have problems with caching in browser or server side, then you get again clear view better with one file. The previous said is only true as long as that one single file size is les then, let say, thousand lines.
ASKER
Hmmm well the file size probly isn't massive....
So I could get away with just having a single js file (actually, it's 2 js files, 1 ajax calls and 1 non-ajax calls) so I guess that'd work OK.
Just thought it was better practise to have many.
So I could get away with just having a single js file (actually, it's 2 js files, 1 ajax calls and 1 non-ajax calls) so I guess that'd work OK.
Just thought it was better practise to have many.
ASKER
No other comments?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Another good tool is YSlow - it's an addon to Firebug and tells you how many HTTP requests your page is making and so fourth etc - check iut out.
Whats your ServerSide Function to join stuff?
Do you use PHP to object bugger then compress with GZip? (if you use php)
Point upped
Whats your ServerSide Function to join stuff?
Do you use PHP to object bugger then compress with GZip? (if you use php)
Point upped
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Would the handler over head - reading the files, selecting the right files for the page, Gziping and then delivery of the files be more then just serving the one file?
Would you cache the output of the JS on your server before it's sent for x time, so if someone else requests the same page you can just shoot them the already packed and compressed singlur js file?
Would you cache the output of the JS on your server before it's sent for x time, so if someone else requests the same page you can just shoot them the already packed and compressed singlur js file?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If you havn't seen it already - would recommend this video
http://video.yahoo.com/video/play?vid=1040890
Thanks very much for your input Eazy, this is exactly the kind of info I was after :-)
I am thinking about creating a PHP class to handle the building of the js files, the caching, gzip etc but I still wonder about the overhead of doing that.
You metioned that you didn't use PHP, are you able to go into a little more depth of how you do this?
More points on the table.
http://video.yahoo.com/video/play?vid=1040890
Thanks very much for your input Eazy, this is exactly the kind of info I was after :-)
I am thinking about creating a PHP class to handle the building of the js files, the caching, gzip etc but I still wonder about the overhead of doing that.
You metioned that you didn't use PHP, are you able to go into a little more depth of how you do this?
More points on the table.
I will get back to you a little later tonight
ASKER
That'd be awesome :-)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice thanks for the links, very similar to what I had invisioned :-)
Thanks very much!
Thanks very much!