I am building full-ajax back-end, which consits of many quite big
partials. As the system grows up, performance is problem. After every
click, partial is refreshed, if needed. I am now at 0.5 sec / request. I
tried to simply disable ajax and the result was quite suprising: the
same page is rendered over 2x faster. I update 80% of page in case of
ajax. (Please dont tell: dont use ajax when updating 80% of page...
thats not the point.) So the ajax (page.replace :partial=>) is
significantly slower than non-ajax? Are there ways to improve
performance? I'am not very deep in rails, some suggestions?
Well the first step is to workout where the bottleneck is (via ruby-prof for example, there's a rails plugin that's easy to use).
Beyond that, it is certainly true that page.replace :partial=> is slower than just a plain old render, since on top of the normal render, the result of the render must be turned into a javascript string (escaping quotes in it for example), and then on the other end the browser does the exact opposite. I remember finding it a big sluggish with large chunks of html.