SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Jun 4, 2001, 23:31 #1
- Join Date
- Mar 2001
- Location
- In a big, big house, with lotsa lotsa room
- Posts
- 1,062
- Mentioned
- 7 Post(s)
- Tagged
- 0 Thread(s)
Disadvantages in using external JS file?
I've been reading the posts here on the advantages of linking to an external JavaScript file rather than having redundant code in every page. Is there any reason not to use an external js file?
Also, can multiple scripts be combined in a single external file without any problems?
Thanks in advance!
-
Jun 4, 2001, 23:40 #2
- Join Date
- Mar 2001
- Location
- Kent, United Kingdom
- Posts
- 5,275
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well personally, I think external .js files are way better - especially if the same code needs to be used on every page. Works the same way as an external style sheet in that, if you need to change a bit of code, you only have to do it the once instead of going through every page with that bit of code on.
As to having multiple scripts in one file. I've done it, so you must be able to
I've also set up additional .js files for scripts that must only be included on certain pages and they work fine too.Saz: Naturally Blonde, Naturally Dizzy!
No longer Editor of the Community Crier.
Don't mind me, I'm having a BLONDE moment!
-
Jun 5, 2001, 06:01 #3
- Join Date
- Feb 2001
- Location
- Van down by the river
- Posts
- 254
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I use external js files all the time. They're much easier to maintain than keeping track of scripts in separate pages. You should be able to combine scripts as much as you please in an external file. The only downside is viewing source - you can't debug your JavaScript by viewing source, you've got to download the js file, alter it, upload it again, and make sure it's not cached, but that's only a minor concern.
-
Jun 5, 2001, 08:47 #4
- Join Date
- Mar 2001
- Location
- the windy city
- Posts
- 281
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I must agree with the previous posters. I use external .js files all the time and find it very convenient in both situations:
1. when the same code has to be repeated on several pages.
2. when I want to keep my html code separately from many long javascript functions. I find it very convenient, since it doesn't create clutter in your documents and helps keeps your code organized and easy to "navigate" (for you, a developer, through it)
Do not feel they have any downsides.
-
Jun 5, 2001, 12:17 #5
- Join Date
- Feb 2001
- Location
- Clearwater, FL
- Posts
- 3,615
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I agree. External links are cleaner and they keep people from stealing your code.
-
Jun 5, 2001, 12:37 #6
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
no they don't...
It is impossible to prevent a determined user from grabbinbg your code (server side code notwithstanding). If I want to take the time to wade through a whole bunch of hoops to get at code that I like, then I will do (and have done) it.Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Jun 5, 2001, 12:43 #7
- Join Date
- Mar 2001
- Location
- In a big, big house, with lotsa lotsa room
- Posts
- 1,062
- Mentioned
- 7 Post(s)
- Tagged
- 0 Thread(s)
Thanks, everyone, for your responses. I wanted to be absolutely sure that there were no downsides before I commited myself.
As usual, you have all been very helpful.
Bookmarks