I included jquery and bootstrap mainly for user experience. When I checked my site’s speed on Google's PageSpeed, it recommended me to remove those libraries in order to boost page speed.

Now, if I remove those libraries permanently then I would be compromising the responsive feature of the website. So I decided to keep a server side check to confirm whether a bot or a browser is visiting my webpage. If a browser visits the webpage then I would include the libraries and if a bot visits my webpage I would not include the libraries.

Is it the right way? Will this affect SEO? Is there any other way I can achieve this?

I'm asking because if I do it this way then the bot’s rendering and browser’s rendering will be different (Though the text content and other contents still remains the same). Is it cloaking?

I found the Q&A "Does blocking content for some users and showing it to Google for indexing affect SEO" but this does not totally answer my situation.

  • Are you loading these from a CDN? If not, then that could be a good step. Dec 17, 2016 at 18:03
  • @AndrewLott Sorry for the late reply. Yes. I am loading from a CDN. Dec 19, 2016 at 14:04

2 Answers 2


There are some people use robots.txt to block css and javascript things from Googlebot and here you gonna hide it from other techniques (May be by checking their user agent or IP address), but Google don't like that. It surely affect on SEO.

Bootstrap contain too many CSS codes which you might not using at all, I have used recently bootstrap and when I do site audits via chrome dev tools, it says 90% css is not used at all in my website, so why should I load them? Then I remove those unnecessary css codes from my bootstrap file. Same thing will apply to Jquery as well.

So optimize your framework, remove unnecessary things and host it on your own server, If your site is minimal and don't require more css then you can directly put your css in head section which will help you to save some time to request another HTTP request to server.

  • I understand your strategy and it is a good one. But if I use CDN method and, maybe, the user already has bootstrap and jquery downloaded, then won't it speed up page loading time? And also, frankly speaking, I am not an expert. It may also happen that I may end up deleting css and jquery codes that my website is using. And also what about updates? If I plan to update jquery or bootstrap, then I will have to do everything from scratch once again. Instead, in case of the CDN method, I will just have to change the link and I am good to go. Dec 19, 2016 at 14:25
  • Yes the cached files, help you to speed up your website, but what if user simply land on your site and leave it without checking your other pages, it means, they load whole css files, and later it is not used by their browser. If you gonna implement third party library then I will say don't think about pagespeed, there is no any perfect solution for them. In last I just want to say don't block those things from bot, because it is bad for SEO as I already said in first paragraph.
    – Goyllo
    Dec 19, 2016 at 18:49
  • Totally Agreed. Just out of curiosity asking, Google bots can only read what we get after viewing the source code of an html page, right?Then how do they get to know what is going on, on the server side? I mean, I know Google "knows all, sees all", but can their bots execute server side scripts? Dec 19, 2016 at 19:19
  • They just don't see html souce code alone, they execute JavaScript as well just like our browser do and read dynamic content that load only when some JS load. Googlebot also use similar webkit, that our modern browser use . Checkout point no.3 here.
    – Goyllo
    Jan 12, 2017 at 18:13

The key to loading javascript quickly is to load it when required and without blocking the page rendering.

Fooling the page speed tool with a server side check is foolish. it wont improve your end users experience of your site, nor will regular google bot be fooled, in fact it may negatively impact your ranking on the mobile index as the page is no longer responsive.

best advice is to look into efficient js loading techniques and optimse the site with requirejs or similar module loader for on demand js.

  • Is requirejs same as the "async" attribute in <script>? I am asking because I already tried with "async" and it is not working in my case. Dec 20, 2016 at 15:19

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.