Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

external js file - local or cross domain?

Status
Not open for further replies.

therake

IS-IT--Management
Joined
May 5, 2006
Messages
1
Location
US
Hello. Apologies for what could be a very newbie question!

I am using an external js file. This file needs to be used on multiple sites so my first choice would be to have all the sites grab it from one location ( Are there any downsides to this? Is there any difference in loading between linking to a local file (relative to each site) and a centrally located file? Does users connection speed factor into reading external files?

Hope this is clear. I am obviously quite new to javascript and its uses. Thanks a bunch for your help!
 
Since you control all the domains, that will reduce the potential problems with loading JS files across domains. The only other problem I can think of is that the site with the JS files may go down while those calling those files wouldn't necessarily follow suit. I imagine other people who have tried this will have some stories from their experiences, too.

Lee
 
Does users connection speed factor into reading external files?
Of course their connection speed will be a factor but it will be no different than any file. Since all of the files have to be downloaded to the client their connection speed is always a factor. The only thing that would make it different for your scenario above is if the .js files were on a server that delivered the files slower than the clients connection speed could download them.
To keep performance up you would want your common link files on a server that can deliver them relatively quickly.


It's hard to think outside the box when I'm trapped in a cubicle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top