Re: Multiple JS Files or Single JS File
Shachar Haad <[email protected]> Mon, 27 Mar 2006 15:45:37 +0200
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
Maninder, Singh wrote: > Hi Everyone, > > Just wanted to take some guidance on the following- > > In my AJAX appication I have a number of js files - > > 1. Some are library specific and hence in different js files. > 2. Some are application specific. > > In case of application specific files, the only reason why I separated the js content in 3-4 files is because it is easier to maintain & makes more sense to keep them separate. > For eg: Some functions are for easy manipulations & are generic so I moved them to utils.js, some are a hash of error messages so I moved them to errorMessages.js and so on. > > If you find that this system works for you, than go ahead and do it. In the end it's what makes you most comfortable that counts. > These 3-4 js files are not huge, they must be around 4-5KB or even less. But, they have been broken up because of the above reason. > > Now coming to my question - is this is a good thing to do or a bad thing? > > Pros (of having mulitple files) - > 1. Easier maintainence > 2. If code is updated in one file, we don't need to download the huge js (sigma of all js's) again > > I think you need to add there "If the code is reusable". meaning, that if you construct a code that you can use in more than one page than you save bandwidth and the code is more easily maintained. > Cons (of having multiple files) - > 1. Would the browser open 3-4 different connections for downloading them? > Since most of my userbase is on dialup, every connection could be costly as compared to only one connection in case of 1 huge js file. > > I don't think that this makes much of a difference. the same thing will happened if there will be one more image on the page. > Well I have been referring to it as a huge js file but it won't actually be huge (wuld be around 30KB..but looks huge compared to 4-5KB :) > > Thoughts? > > Thank you, > Mandy. > > > Unsubscribe > [email protected] > > List info > http://www.quirksmode.org/dom/list.html > Yahoo! Groups Links > > > > > > > > Unsubscribe [email protected] List info http://www.quirksmode.org/dom/list.html Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wdf-dom/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/