backbone vs turbolinks for search engine with rails 3.2 - ruby-on-rails

I'm working on a small search engine with tire and elastic search. I just started the project and I would like the search to be as fast as possible.
What technology should I use for this purpose, turbolinks or backbone.js?
Also. I would like to know how I can solve the problem of "Seo" with these technologies.
thanks

Using Backbone with ajax requests will be slightly faster than using Turbolinks.
However, Turbolinks will provides SEO by default, whereas you have to do a lot of work to make Backbone and SEO work (See this StackOverflow question)
You'll also have to write a lot of JavaScript if you use Backbone compared to writing hardly any JavaScript if you use Turbolinks.
It's really up to you to weigh the pros and cons and decide which option is better for your situation though.

Related

Can AngularJS architecture interfere with a framework like Ruby on Rails at some point?

I have a web application that has most of it's logic on ruby on rails, and lately I've been getting good at AngularJS but I'm not a master at it. What I like about angular is that it lets you be very declarative on your javascript code knowing if an element is being referenced on the html unlike jquery. Also it has nice filtering options but that would not be needed cause rails handles that on the server-side. Is AngularJS meant to work as a stand alone framework or it can coexist with server-side frameworks?.
This is more of a discussion question, so not an ideal SO question.
Angular and Rails can happily coexist.
You can use the asset pipeline and load Angular, in the same way that you would any other JS library.
There is a good tutorial here, also, this Railscast is quite handy although it is a bit out of date now.
My advice is to have a crack at it, and then come back to SO and post specific bugs or challenges you are hitting.

Integrating rails & angularjs

I tried Angular, and I liked it. I've began to integrate him into my rails-app, but then appeared some doubts about architecture
Routes. I would like to navigate without refreshing the page, before i used Wiselinks gem, it's easy and cool - just install, patch link_to helper and done. But angular have his own router, and ui-router (which is cool). I want my app to be running at the browser like Opera Mini and IE, but ui-router doesn't have such callbacks as in wiselinks. I wouldn't create mobile site version - the design is adaptive yet. It means, I would use rails routing, but I want to AJAX page refreshing when it can be (progressive enchansement, yep). What do I do?
In many places, the content is rendered by Angular, i.e. a list of posts (by ajaxing json). That fast & cool on desktop, but again old browsers! I need to render it on server for them. Or I haven't?
I'm stuck. Thanks.
This would be best trip to angularjs + rails 4...
This post clear my doubts and now i m very clear about architecture, routes, controllers, model, etc..
http://www.honeybadger.io/blog/2013/12/11/beginners-guide-to-angular-js-rails
I hope this solves your DOUBTs
and to know further about angularjs visit
http://www.angularjs.org
It's not necessary that you have to use angular routing. You can use ng-controller directive to inject controllers in your view.
Angular in general is very fast. I have been using it even in mobile browsers, it works like a charm. True if do heavy $scope manipulation, things might get little slow.
Talking about old browser support, till IE8, you are pretty good, if you follow http://docs.angularjs.org/guide/ie as already mentioned by shaunhusain, but below that I am skeptical.
I wouldnt recommend using wiselinks alongside with angular. We have tried that in a production app and it took us a long time to make this work, there had been so many issues with undead scopes and other artifacts.
Therefore, we have ended up throwing out wiselinks and replacing it with a similar directive written in angular. This way its easier to avoid problems when destroying or compiling dom.

pjax vs turbolinks vs cache_digests to improve rails speed?

I've done some reading about the various options for improving the speed of a rails site.
The following libraries seem promising:
pjax
turbolinks
cache_digests
However, it seems like they try to do many similar things.
Can/Should you use them in tandem? Are there problems that would arise in doing so?
Are there cases where one or the other is better than the rest? (And what are they?)
Is there something superior to all three I should check out instead?
I prefer pjax. It's easy to use and very fast. You just have to define a pjax-container which will be replaced every request.
Turbolinks instead does replace the whole body. I don't like that very much. But that's matter of taste. It will be part of Rails 4.
cache_digests is not something that can be compared with pjax or turbolinks.
cache_digests enhances Rails caching to allow for Russian-doll caching.
Turbolinks tends to be a bit more straightforward and doesn't require jquery.
Pjax is configurable but required jquery.

Is it a good idea to use emberjs only in some pages when using rails?

I have a rails app that has pretty standard things, except for two pages that require a lot of JS.
I was wondering if it's a good choice to use ember just for those two pages while keeping Rails standard for everything else? Or should I rewrite everything in emberjs + rails as API backend?
This is really a case-by-case situation. Why do those two pages require a lot of JS? The answer is probably "because of an implementation decision you made." Adding Ember to the mix is probably going to prompt you to revisit a lot of implementation decisions to reconsider which tools are appropriate to use in which places.

Rails future & Javascript

David H.H. announced recently that jquery is going to be the default in Rails 3.1, and that Prototype helpers / RJS are going into a gem.
What does that mean for the future? Should we progressively forget about things like javascript helpers, RJS, and all these fun parts of rails? And start coding with jquery/json in mind?
I'm not against that at all, but I have to admit I find RJS really fun to use...
Yes, unobtrusive JavaScript has won. Many people write now directly JS / jQuery code in ERB templates. jQuery code to replace some DOM node with a partial is only slightly longer than equivalent RJS code. Regarding JS helpers, it should be quite easy to replace all of them with unobtrusive JS code. Check how data-remote is handled in jQuery Rails driver.
This trend makes sense because web apps have more and more JS code which cannot be written in RJS. It is better to use two languages than three.
If you don't like JavaScript syntax then check out CoffeeScript. Which will be definitely more popular than RJS.
Long term future probably belongs to pure JS frameworks like SproutCore. Server side will process only JSON data. However these new techniques will be used only in new apps. Generally it doesn't make sense to upgrade existing apps to the new model.

Resources