I have an XML-feed with references to rather large external image files (200kb). They are causing really long load times which in turn cause the page to crash. In one div I load 20 images like this. Each div is loaded in a separate partial. These partials (product
_item) take between 40-400 ms to load (!), mostly because of the large images.
The external images needs to be external (so any AWS solution) will not work.
The "slow-portion" is below the fold and could easily be hidden 'until needed'.
<div id="slow-portion">
<% @product.each do |product| %>
<%= render 'product_item' %>
<% end %>
</div>
I just implemented lazy load of the images (http://www.appelsiini.net/projects/lazyload) which I thought would solve this problem but it seems like the page will still wait until everything is loaded (including the large image files) before it shows the page. The load times for each product_item is still the same.
This is getting quite frustrating so I wonder, in quite general terms, how I should address this problem.
- Is it possible to timeout a partial in Rails. I.e. if "slow-portion" has not been loaded in 3 seconds, it should not show?
- Should lazy load of images solve this type of problem? I.e. is this where I should trouble shoot the problem?
- Can I solve this with ajax-loading of the slow-portion of the page? Basically, that portion will show a "Waiting symbol" until the "slow-portion" has been fully loaded?
- Is there any other ways of not causing a crash (503 error) and timeouts due to view-load times being too large?
Any solution that will work is fine for me!