Google and JS...?

  • cdx
  • Graduate
  • Graduate
  • User avatar
  • Joined: Apr 16, 2004
  • Posts: 103
  • Loc: Israel
  • Status: Offline

Post September 12th, 2004, 3:45 am

Hi all...

I heard that it's important for the ranking/indexing in google- to take off the JS code from the HTML and make it external .JS file.

Is it true? Why should it matter? I guessed that google knows how to handle Js codes...

I have about 30-40 lines of JS in most of pages, how to make it external Js file?

Thanks in advance,

Guy.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 12th, 2004, 3:45 am

  • Jess
  • Guru
  • Guru
  • User avatar
  • Joined: Sep 10, 2004
  • Posts: 1153
  • Loc: USA
  • Status: Offline

Post September 12th, 2004, 3:55 am

http://www.javascripter.net/faq/externa2.htm

That tells you how to make an external js file.
  • cdx
  • Graduate
  • Graduate
  • User avatar
  • Joined: Apr 16, 2004
  • Posts: 103
  • Loc: Israel
  • Status: Offline

Post September 12th, 2004, 4:10 am

Thanks Jess, I just your other massage.. ;)

Anyway, there is any problem for google to read Js? and even if not, what is the best way (and why...) to run JS in a website, externally?

Thanks for all, I love this forum... ;) !

Guy.
  • Jess
  • Guru
  • Guru
  • User avatar
  • Joined: Sep 10, 2004
  • Posts: 1153
  • Loc: USA
  • Status: Offline

Post September 12th, 2004, 4:29 am

CSS and javascripts in separate files means:
You get your text closer to the beginning of the page, the robot doesn't have to wade through lot's of CSS, Javascript and HTML-code to find your content.

Thats pretty much the extent of it. I find its good practice to just put javascript code into a js file and link to it, it keeps the code looking a lot cleaner also.
  • Managedlinks
  • Proficient
  • Proficient
  • No Avatar
  • Joined: Mar 31, 2004
  • Posts: 294
  • Status: Offline

Post September 12th, 2004, 6:22 pm

Another advantage of externalising JS is it reduces the page load time, that is if you use the same JS in multiple pages, which is very common. the browser loads the JS file only once. saving that number of bytes per web page.

There is a gotcha about JS you should be aware of cdx.

if you use JS to "create" your page content then a search engine spider will ignore it, and your page won't get indexed
(in other words your JS has lots of document.print("page content text") statements)

So use JS to give your page functionality not content
  • phaugh
  • Professor
  • Professor
  • User avatar
  • Joined: Sep 30, 2003
  • Posts: 796
  • Status: Offline

Post September 12th, 2004, 11:43 pm

Another bonus is when you want to update the js or css code you only have to do it in one place...not on every page....probably the biggest plus since most common js and css code is not very long it won't affect the size of the page too much and JS doesn't always have to be at the top of the page...just before the event that calls it.
  • Jade456
  • Student
  • Student
  • User avatar
  • Joined: Sep 10, 2004
  • Posts: 87
  • Loc: Las Vegas
  • Status: Offline

Post September 13th, 2004, 1:10 am

Better for "slimming" your site. Having a reference file is a lot easier. And as others have stated, it will reduce load time and you only have to update one place should you need to.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 22 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.