1

i'm creating a website and i'm thinking of ways to make it load as fast as possible. My website, as it happens with most, has a layout that is the same for every page. For instance, the header, the external divs and so on are defined once in a layout and used likewise for every page that loads. The menu is always on the leftest div and never changes, and so on.

So, think of 5 areas. Top, left, center, right and footer. In my case, only the center has to change, depending on the page that i want to load. Therefore, i was thinking that using Ajax to do that would make loading way faster, since all other elements would already be loaded, right ?

So, i would like to ask whether there is a good resource or online tutorial that discusses this matter, as i would like to take a close look.

Thank you for reading that :)

Spyros
  • 46,820
  • 25
  • 86
  • 129
  • 1 image in the content would probably render this optimization useless. The amount of data you are saving from not loading the header/foot is probably not much considering most of it should be cached. I'd look at the standard ways of optimizing the page first.http://stackoverflow.com/questions/808601/how-to-optimise-site-load-times-in-ruby – Byron Whitlock Jan 11 '11 at 20:26
  • 1
    Beware, ajax may drift towards clumsy apps if you don't uphold web basics: one page = one url. Why don't you cache the parts of your app you use again and again? – apneadiving Jan 11 '11 at 20:26
  • why is that ? I don't really get it. – Spyros Jan 11 '11 at 20:29
  • @apneadiving, i will use one page = one url anyway. It's just an optimization of loading that page inside the content and not reloading everything. However, i think that caching may be a very good option indeed. – Spyros Jan 11 '11 at 20:31
  • A reason why i was leaning towards ajax is that i have a tab like environment that works with javascript and preloads everything on every tab. Maybe it would be better to change that and use caching as well. – Spyros Jan 11 '11 at 20:33

2 Answers2

0

I'd advise you to avoid RJS because it's server-side javascript.

Use regular Ajax calls with the JS framework you like. A good asset here: http://peepcode.com/products/jquery-ajax

apneadiving
  • 114,565
  • 26
  • 219
  • 213
0

Regarding @apneadiving's comment on caching the parts of the app, you'd use the fragment caching to handle that. http://api.rubyonrails.org/classes/ActionController/Caching/Fragments.html

You can load contents of the "main" part of your page using the approach here (using jQuery) Replace HTML page with contents retrieved via AJAX

Unless you know that your site's performance is unacceptable and that ajax will fix an issue you should probably avoid complicating things by using ajax. Remember premature optimization is the root of all evil :)

Community
  • 1
  • 1
StevenWilkins
  • 1,313
  • 8
  • 18