File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Which is quicker Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Which is quicker" Watch "Which is quicker" New topic

Which is quicker

Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Loading JS from an external file or loading it in a <script> tag in the head section of the page?
[ January 21, 2008: Message edited by: Bear Bibeault ]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Well it depends on what you are doing. Is the extrenal file packed? Are you gzipping things?

The external file will contain the same information only real difference is you need to make another http request to get that information. The external file will get cached so it will be faster on multiple hits. That is where he benefit is.

Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Well I want to create a dynamic Search Results Page. And the information that is displayed as header information vs being put in the table is based on the criteria the user searches by. Right now there are 7 different combinations for the user to search by. I'm thinking this could get my javascript to be pretty long if I'm trying to write different jQuery code for each example. So I though about packaging it up in an external file and break it all down into classes based on the criteria. Then just call the classes I need.

Sound like a good candidate for external JS file that is gzipped? This would be dom manipulation and jqGrid creation. Basically I will have a couple of divs that I'll ID and then do my changes to them.

I think I've talked myself into doing most of it external.

If you have any thoughts please let me know...
I agree. Here's the link:
subject: Which is quicker
It's not a secret anymore!