Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Is it OK to block my javascript files in robots.txt, or can it hurt my website SEO-wise?

share|improve this question

3 Answers 3

You don't state the reason to do that, so the general answer is no.

JavaScript files are not usually crawled, search engines know they are there, but they usually don't do anything with them because they don't have any content for users. So there is no need to do that from the Search Engines/Crawlers perspective.

From the perspective of normal users, it makes less sense because users don't use the robots.txt file and if they want to check your JavaScript files, they can access them directly after checking your code.

About the specific question, no, it won't hurt your SEO in any way because is basically a rule that nobody would pay attention to it.

Potentially may affect you badly if you make a mistake and block a folder that has content, but assuming you won't make that mistake, there is no benefit or drawback.

share|improve this answer
    
Would a search engine bot that supports/runs JavaScript still access (not index) the JS files? –  unor Mar 27 at 16:36
1  
You should not block JavaScript from being crawled because search engines (ie. Google) DO crawl (and execute to a certain extent) these files and if your content is dependent on the execution of this JavaScript, in any way, then it could hurt your SEO. Matt Cutts (Google) - March 2012 - Don't block Googlebot from crawling JavaScript and CSS @unor Yes. –  w3d Mar 28 at 0:07
    
Yes, they can detect and execute, for instance, AJAX request for content and follow forms activated by JS. –  PatomaS Mar 28 at 0:58
    
What if I don't want them to execute AJAX? –  getbuck Mar 29 at 23:04
    
In any case, you can´t really block acces to anything on robots.txt. So if you want to prevent crawlers to execute the JS files, then it´s better to block them by oter meanings, like .htaccess. But be careful, that may end up on creating problems to your ranking on search engines, if you don´t mind the potential problem, then it´s ok. –  PatomaS Mar 30 at 4:31

It would certainly hurt your SEO for code search engines.

share|improve this answer
    
what's a code search engine that is functional as of today? I absolutely don't want my code to be searchable. –  getbuck Mar 27 at 17:10
    
@getbuck: I have no first hand experience; I’d guess there are countless (just like there are countless general search engines), though many probably only index FLOSS code. --- It seems that NerdyData got some hype recently. –  unor Mar 27 at 17:29

After Panda 4 update (May 2014), blocking css & js files will kill your seo.

There is a nice case study here that shows how doing that can hurt SEO :

https://yoast.com/google-panda-robots-css-js/

Nowadays Google wants to see your pages as same as users, so it is important to let him to see your client side scripts and style sheets.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.