View Full Version : isolating script
Jon Dapron
04-08-2004, 09:52 AM
Hi,
I have a page with multiple javascripts in it - see www.tools4flooring and check the source. Could someone tell me how to isolate out the javascript and reference them? Ive heard this makes it easier for spiders.
Open up notepad, copy each individual script into a new text file, and then name them something relevant with the extension .js.
And then on your page use <script type="text/javascript" src="javascript.js"></script>
Jon Dapron
04-08-2004, 10:22 AM
thanks, so naming this file javascript.js wouldnt cause any problems, right?
No, just name it something relevant to what the script does, like rollover.js if you were using that for rollover buttons.
But in those .js files, the only thing in there should be javascript, no html.
Jon Dapron
04-08-2004, 12:01 PM
do i isolate out the <noscript> tag as well, or leave it in my html under the link to my file. Also, in the external javascript file, do i include the script tags at the top and bottom, or just what was between them? Thanks!
agent002
04-08-2004, 12:04 PM
leave the noscript tags on the page, and don't include any HTML tags in the .js file (not even the <script></script> tags). :)
Vincent Puglia
04-08-2004, 05:00 PM
Hi,
To expand upon what was said above:
1) the *.js file can contain only javascript and comments
eg:
/*------------------------
my js file that contains the
following functions and vars
function doit()
function showit()
var isOK
---------------------------*/
var myArray = new Array(); // declare the array
myArray[0] = '1st string'; // fill it
myArray[1] = "<script type='text/javascript'>";
Note: the html script tag in myArray[1] is ok because it is a string and therefore will not be confused with a command
2) do not call the file 'javascript.js' or anything that even remotely resembles a keyword -- you never know how the browser will react to it, and in some cases, you really don't want to know.
Vinny
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.