Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Valentin Berlin
14,346 PointsSearch engines and JS
How do search engines treat the content of JS arrays? If I store one inside HTML file that's using it, will it be indexed and searchable?

Dave McFarland
Treehouse TeacherI believe that Google will render the page and follow the "links" that load the new content via AJAX. So, I think the answer is YES, the content added via AJAX should be indexed.
I think you should try out the "Fetch as Google" tool -- in particular the "fetch and render" functionality: https://support.google.com/webmasters/answer/6066467?rd=1
3 Answers

Dave McFarland
Treehouse TeacherAs Ken Alger pointed out Google is not taking into account both CSS and JavaScript as part of the SEO. This doesn't, however, mean that Google will analyze your CSS and JavaScript files. In other words, they aren't going to look directly at the data inside an array, for example.
Instead, Google will now "fetch and render" your pages -- that is, they'll look at the rendered HTML of your pages after CSS and JavaScript have done their magic. I believe this means that if you hide a page element with JavaScript or CSS, that hidden content won't be indexed.
Google is now offering a tool -- "Fetch as Google" -- that will help you "see" what Google's search engine sees as it visits your site. You can learn more about it at: https://support.google.com/webmasters/answer/6066467?rd=1

Ken Alger
Treehouse TeacherMy question about this then would be if they are only indexing the rendered pages, why are we going to be penalized (SEO wise) for not "granting access" to the full CSS and/or JavaScript files? Would their bots, in this particular example, scan through a script.js
file and discover the array information? Or are they just not caring what is in there?
I know that with most search engine algorithms it is an "educated guess" as to what makes them tick, but it would seem to me that if the engine docks SEO points for not allowing access to a script file that it should take into account the full file if it does have access.
I do think the newly updated Fetch as Google tool will be greatly useful for SEO work.
Thanks for all you do,
Ken

Dave McFarland
Treehouse TeacherGood questions, Ken. I don't really have an answer though :)
I'm no SEO expert -- I'm just guessing based on what I read in Google's announcement. I haven't played with Google Fetch yet, but since Google is basically saying that they are going to be looking at the rendered page (after CSS and JS do their stuff on it), I think the next step for people interested in this is to start testing their pages with Google Fetch.

Ken Alger
Treehouse TeacherDave;
Thanks for the information. Perhaps someone who concentrates on SEO, like Dan Gorgone, would have some insight. My small, limited, testing with Google Fetch showed that it grabbed array data, but who knows how their algorithm will handle that for SEO purposes.
Ken

Ken Alger
Treehouse TeacherValentin;
That is a great question. Google just announced the other day that they are changing the way they are handling JavaScript and their SEO calculations. That may have a dramatic effect on the SEO world shortly that would change any answer you may have gotten a few weeks ago.
My understanding is that now Google wants to be able to access full JavaScript code in order to provide better SEO numbers for a site. Not entirely sure how that translates into the real world in terms of positive/negative effect, but it is certainly something to think about.
Ken
Valentin Berlin
14,346 PointsThank you both very much for your input. It's very helpful!
Valentin Berlin
14,346 PointsValentin Berlin
14,346 PointsAlright, but what if I have a single-page site where the content gets dynamically updated with HTML partials via Ajax calls and text blocks kept in a JS array, would those partials and especially the text in the array be crawled despite not being anchored on the index page?