Hiding Javascript

F

Fred

IBP tell me that I have too much javascript text on my pages and advises me
to "hide" the script by placing it in a file called something like
myscripts.js and then telling the page to find the script by adding <script
src="myscript.js"></script> to the page. Can someone advise my how this can
be done and what I have to place in the <head> and again in the <body> to get
this to work. I've tried but failed so far.
 
K

Kathleen Anderson [MVP - FrontPage]

Assuming the page you want to add it to is in the root of your web, and the
script file is in a folder called scripts, putting this:

<script LANGUAGE="JavaScript" SRC="scripts/myscript.js"></script>

in the body should work.

Adjust the SRC to suit your file locations.

--

~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.spiderwebwoman.com/resources/
Please reply to the newsgroup for the benefit of others.
 
M

Murray

Actually, to follow standards you'd do this -

<script type="text/javascript" src="scripts/myscript.js"></script>

You would put it just above </head>.
 
F

Fred

Hi Murray,
They say that search engine spiders use the long script in the word count on
the page and therefore it reduces the count of the keywords plus moves the
useful text further down the page. Not sure if this is true but enless I can
find a way of hiding the script i'll just have to run with it.
 
K

Kathleen Anderson [MVP - FrontPage]

Murray said:
Actually, to follow standards you'd do this -

<script type="text/javascript" src="scripts/myscript.js"></script>

You would put it just above </head>.

I'm not sure that's true in all cases. On this page
http://www.core-ct.state.ct.us/employee/ it's in the <body>, placed where
the output of the script should be displayed on the page.


--

~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.spiderwebwoman.com/resources/
Please reply to the newsgroup for the benefit of others.
 
M

Murray

It doesn't matter where in the page you place links to external js files
that contain only function definitions. Obviously, if they also contain
executable directives, you would need to place them at the location where
the output would be needed.
 
?

.._..

Actually, it is not nonsense.

The issue is the first 250 lines the file is all _SOME_ search engines look
at. If you use up 200 lines with JS code, you don't get the words listed as
well.

That said, the search engines that are important (Google, MSN, and one
other) do not do this, so the advice can be safely ignored for the most part
because the searches that account for most visitors don't suffer from the
problem. But it is not BS. It's just not important.

(There are other good reasons to use JS files, if they exist on more than
one page, they will get cached and increase (shorter download) the speed at
which users get the content fully loaded. And, you don't have to go
changing every file in the site when you want to make an update.)
 
M

Murray

That's baloney. SE's are quite smart enough to know what is content and
what is not.

But of course there is good reason to externalize your js - however SE
ranking is not one of them
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top