We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Large javascript code options....; in page code or external .js file?
Topic Started: Sep 11 2005, 07:23 PM (346 Views)
AndrewF31
Member Avatar
Otorrinolaringologista
[ *  *  *  *  *  * ]
Hey, just a quick question. Not really sure which is better or more efficient if there's any advantage at all.

Imagine you're using a hefty javascript code on your site and you have your own hosting. What is the better option:

a. post the whole code in the html, php document

or

b. post the <script> code in an external .js file then call it with the html code

Which option makes the page load faster, more efficiently? Keep in mine the external .js is hosted at the same place.
I'm not really sure if it makes much of a difference. There's less raw code for the browser to read when loading the page in the beginning but eventually it will have to go into the external .js file and read the code.

Thanks for your help!
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
It caches the external .js file so that's the better option.
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member
[ *  *  *  *  *  *  * ]
Plus, it's easier to read. Unless it's a really short one, I'd just stick with external.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply