Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Putting Javascript Code In A Separate File


This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1 RisaBB

RisaBB

    HR 4

  • Active Members
  • PipPipPipPip
  • 122 posts

Posted 02 August 2003 - 09:58 PM

Hello,

I read as one of the tips to put the javascript code in a separate file and not in the head of the document.

I just started doing external scripts and SSI, and I thought that even though my code says <!-- include file... -->, when I view the source code online, all the code from the external file is put into the file I am viewing, so doesn't that defeat the purpose since the code ends up being there anyway?

Thanks,
Risa

#2 Scottie

Scottie

    Psycho Mom

  • Admin
  • 6,294 posts

Posted 02 August 2003 - 10:10 PM

hi Risa! Welcome :manybounce:

SSI is server side includes- meaning the page is built (parsed) by the server and delivered fully coded to the browser.

It's different than javascript code which is called and processed but not actually written on the page.

Hope that helps!

#3 qwerty

qwerty

    HR 10

  • Moderator
  • 8,621 posts

Posted 02 August 2003 - 10:10 PM

Nope, a server side include is not the same thing as calling a remote script. In the former, the server builds the html for the complete page by throwing the code from the included page into the main page, as you've described.

But in the case of calling a style sheet or a script, it does not get written into the page by the server. Instead the browser goes out and grabs it as soon as it hits the code that calls it. Moreover, the script (or the style sheet) then gets cached, so any additional pages that use them will load faster.

#4 Scottie

Scottie

    Psycho Mom

  • Admin
  • 6,294 posts

Posted 02 August 2003 - 10:24 PM

LOL, Bob!

We must have hit the submit button at the same time. :manybounce:

#5 qwerty

qwerty

    HR 10

  • Moderator
  • 8,621 posts

Posted 02 August 2003 - 10:26 PM

Yup, I think I'm going to need to practice my typing if I ever hope to beat you to the punch.... er, post :manybounce:

#6 robwatts

robwatts

    HR 5

  • Active Members
  • PipPipPipPipPip
  • 308 posts

Posted 03 August 2003 - 01:23 AM

Just to add to what has been said by Bob and Scottie

You can reference the javascript by refering to a *seperate* file named whatever.js This file would contain the javascript required by your various function calls.


<head>
<script language="JavaScript" src="whatever.js">

</head>

So, instead of having multiple lines of javascript in the head of your document, you just have the one. Thus reducing your page size.

#7 Marc

Marc

    HR 3

  • Active Members
  • PipPipPip
  • 90 posts

Posted 07 August 2003 - 02:01 PM

Hi Risa,

I've been running javascript in the head of documents for a looong time...never had any problems with engines..if that's what your concern is. I've run single and multiple head scripts also without anything unusal happening.

Take Care!

#8 dragonlady7

dragonlady7

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 618 posts

Posted 07 August 2003 - 02:15 PM

But, a reminder: Google can now index external .js files, so don't hide anything in there for whatever reason.
(We don't know if it really parses them, but we don't know what else it would be doing with them...)

#9 qwerty

qwerty

    HR 10

  • Moderator
  • 8,621 posts

Posted 07 August 2003 - 02:21 PM

... and if they're doing that, I can only think of one reason for it: they're checking to see if you're doing anything non-kosher. Because of that, don't put your external scripts or style sheets into directories to which you're disallowing access by spiders.

#10 RisaBB

RisaBB

    HR 4

  • Active Members
  • PipPipPipPip
  • 122 posts

Posted 07 August 2003 - 08:21 PM

Hello,

I've tried all day to get my external JS file to work, to no avail. I don't really know how to write javascript. My pull down menu was generated using Fireworks.

I'm doing this so that spiders can crawl my site more easily without going through all that code. I got this tip from a posting here.

How important is this? I really feel like giving up trying to do this external js file, but if it's really important, maybe I'll pay a js coder that I know to make it work for me.

What do you think? Thanks.

Risa

#11 Marc

Marc

    HR 3

  • Active Members
  • PipPipPip
  • 90 posts

Posted 07 August 2003 - 08:32 PM

Hi Risa,

Well, I've been running scripts in all of my pages for years without any Engine problems, I run 2 corporate websites that rank in the top 10 (pharmaceutical industry) with scripts intact. I wouldnt worry about using scripts in the head or body of your pages.

Take Care! :zap:

#12 Jill

Jill

    Recovering SEO

  • Admin
  • 32,967 posts

Posted 07 August 2003 - 09:47 PM

It's really not all that important to the search engines. They have no problem ignoring your javascript.

It's just a nice thing to do. Makes the file size smaller, makes it apparently easier to find "the meat."

But it's absolutely not something that is critical to your search engine rankings, contrary to what you may have heard!

But, a reminder: Google can now index external .js files, so don't hide anything in there for whatever reason.
(We don't know if it really parses them, but we don't know what else it would be doing with them...)


My guess is this is simply GoogleGuy propaganda to scare people into not trying to trick them through their javascript.

Sad that people need to be threatened in order not to use tricks though. :hmm:

Jill

#13 Dragon

Dragon

    SEM Captain

  • Active Members
  • PipPipPipPip
  • 162 posts

Posted 08 August 2003 - 01:39 AM

Sad that people need to be threatened in order not to use tricks though.


This is one thing that I just cannot fathom at all in the SEO industry. SEO to me is so fascinating trying to stay ontop & ahead of the game (as long as its done ethically) ; I love the challenge it brings & still feel the thrill of reaching top 10 rankings with every new project (or even page) launched! :lmao: I can't understand that there are still people out there going around "partying like its 1999!!" :notworthy: although I have come across many, many sites that still do...By the way, well done Jill to an awesome forum!




SPAM FREE FORUM!
 
If you are just registering to spam,
don't bother. You will be wasting your
time as your spam will never see the
light of day!