Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graceful degradation with angular/ rails

I have two versions of a page: one written using angular, another without any javascript at all. How could I get rails to detect if the client has javascript disabled (or is a googlebot) and serve up the page with no javascript?

like image 420
Rob Avatar asked Oct 21 '22 19:10

Rob


1 Answers

You can redirect the client to another URL (that executes an Rails controller) and set a default layout with no Javascript.

<head>
    <!-- title, scripts, css etc go here -->
    <noscript>
        <meta http-equiv="refresh" content="2;url=http://yoururlgoeshere.com/yourcontroller">
    </noscript>
</head>

This works well with crawlers like googlebot and etc. With this you decrease the traffic of your server when your site indexed by a search engine because you can leave out css files, image files and js files.

I hope this helps.

like image 77
danilodeveloper Avatar answered Oct 27 '22 10:10

danilodeveloper