Welcome to WebmasterWorld Guest from 54.146.180.94

Forum Moderators: open

javascript .js source files...

Do all browsers import an external javascript file?

   
4:38 pm on Mar 19, 2003 (gmt 0)

10+ Year Member



For all intents, can you assume your users browser supports external javascript source file includes? What is the best line to use to include an external javascript file that is compatible with say at least IE 4+ and Netscape 4.7+?
4:42 pm on Mar 19, 2003 (gmt 0)

10+ Year Member



Not really an answer to the question, but an extra point.

Howe can be sure your browser consistently imports external JavaScript and css files?

When using IE5+, I notice quite often that an external stylesheet or script file isn't imported, often with catastrophic consequences...

4:42 pm on Mar 19, 2003 (gmt 0)

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member



<script type="text/javascript" src="myjspage.js"></script>
5:06 pm on Mar 19, 2003 (gmt 0)

10+ Year Member



why is it not imported?
7:35 pm on Mar 19, 2003 (gmt 0)

10+ Year Member



ALL modern browsers will understand reading external javascript files. I think even Netscape 2.0 could do this. All CSS-aware browsers can read external CSS files as well.

The javascript file won't be called if the user has javascript disabled - which is the case for about 10% of users. Also, search bots such as Googlebot won't call it as they don't look at javascript.

As for CSS, it is rarely disabled in the end-user's browser, so it will be called in most cases (except for the bots again).

Use:
<script type="text/javascript" src="myjspage.js"></script>

for javascript, or

<link rel="stylesheet" type="text/css" href="mystyles.css">

for CSS.

9:33 pm on Mar 19, 2003 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The issue isn't whether the browser can import external javascript files or not.

The issue is whether the browser actually understands javascript in the first place, and if it does, whether that feature is still enabled, or whether it has been disabled by the user.

For javascript-enabled browsers it does not matter whether the code is inside the HTML file, or is in an external .js file. The code will be treated the same way.

External javascript files make for a neater HTML page, allow code re-use across the entire site, and easier updating of the code. External javascript is the way to go.

1:00 am on Mar 20, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



When using IE5+, I notice quite often that an external stylesheet or script file isn't imported, often with
catastrophic consequences...

Yes, there's a bug there and I can't pin it down. I heard others mention it, but never saw it myself until a recent rebuild of this machine.

Now, even after trying three different builds of IE6, I am still stuck with it.

It's got to be relatively rare - some combination of browser plus OS plus other software of something like that. Else we'd have heard a loud complaint long ago.

9:23 am on Mar 20, 2003 (gmt 0)

10+ Year Member



> It's got to be relatively rare

I agree. I often it see with my own browser/OS setup it on a VERY high traffic site of ours, but I haven't heard of any complaints through customer services...

However, still fairly worrying. Even if it affects only 1% of users, that can work out to be a lot of users that may hit the back button.

I'd love to hear of a solution, but I can't believe that it would involve anything other than a reinstall of user software, which is sadly beyond our control.

9:29 am on Mar 20, 2003 (gmt 0)

10+ Year Member



By the way, I'm using IE5.50 on Win 98 Second Edition ver 4.10 if we want to start a comparative list.

I'm wondering if it's anything to do with some kind of scumware? i.e. something that interacts with the browser itself.

I've tried strenuously to avoid getting scumware on my box, but while I was away a while ago I think somebody else may have inadvertently installed some...

9:13 pm on Mar 20, 2003 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Something like AdAware from Lavasoft will quickly tell you what is there, and offer to clear it all away for you.

Be aware that it can give false alarms. A program that I use to plot the paths of Comets through the Solar System, installed as something like C:\Program Files\Comet\comet.exe was incorrectly identified as being a component part of Comet Cursor for example.

4:25 am on Mar 24, 2003 (gmt 0)

10+ Year Member



universalis wrote:
>I think even Netscape 2.0 could do this.

No. Although netscape supported JavaScript (SCRIPT element) from version 2.0Beta3, SRC attribute was supported from version 3.0Beta3.

Incidentally, IE supported the SCRIPT element from version 3.0Beta1, and also supported the SRC attribute from version 3.02.

5:49 am on Mar 24, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



anything to do with some kind of scumware?

Like those new RealOne message pop-ups I just started seeing, maybe? I've been looking for candidates in the most recent stuff, because I never saw the bug until the last few months. That obnoxiously invasive RealOne Player is high on my suspect list right now.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month