Google and JS...?

  • cdx
  • Graduate
  • Graduate
  • User avatar
  • Posts: 103
  • Loc: Israel

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Jess
  • Guru
  • Guru
  • User avatar
  • Posts: 1153
  • Loc: USA

Post 3+ Months Ago

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

That tells you how to make an external js file.
  • cdx
  • Graduate
  • Graduate
  • User avatar
  • Posts: 103
  • Loc: Israel

Post 3+ Months Ago

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
  • Posts: 1153
  • Loc: USA

Post 3+ Months Ago

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
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

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
  • Posts: 796

Post 3+ Months Ago

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
  • Posts: 87
  • Loc: Las Vegas

Post 3+ Months Ago

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 4 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.