6

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

3 Answers 3

4

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.

2
  • This is the correct answer! View also Matt Cutts video: youtube.com/watch?v=B9BWbruCiDc Commented May 21, 2018 at 16:24
  • Although I suspect that since it's a link in the page that is being crawled, Google will read it anyway. Commented Sep 25, 2022 at 22:00
0

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.

7
  • Would a search engine bot that supports/runs JavaScript still access (not index) the JS files?
    – unor
    Commented Mar 27, 2014 at 16:36
  • 3
    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.
    – MrWhite
    Commented Mar 28, 2014 at 0:07
  • Yes, they can detect and execute, for instance, AJAX request for content and follow forms activated by JS.
    – PatomaS
    Commented Mar 28, 2014 at 0:58
  • 1
    What if I don't want them to execute AJAX?
    – getbuck
    Commented Mar 29, 2014 at 23:04
  • 1
    @PatomaS: "if you want to prevent crawlers to execute the JS files, then it´s better to block them by oter meanings, like .htaccess." - Good bots obey robots.txt. By disallowing crawling of JS files in robots.txt you will prevent bots from executing these files.
    – MrWhite
    Commented Mar 31, 2014 at 10:18
-1

It would certainly hurt your SEO for code search engines.

2
  • what's a code search engine that is functional as of today? I absolutely don't want my code to be searchable.
    – getbuck
    Commented Mar 27, 2014 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
    Commented Mar 27, 2014 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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