Currently I’m using:
<% @items.each do |item| %>
<li class="list-item">
<%= render :partial => '/widgets/vertical_widget',
:object => item %>
</li>
<% end %>
to render about 20 items on a page (there’s also another 20 of a different widget on the same page).
When I look at my server logs it’s showing ~400ms per widget render, totaling out to ~20k ms for the page. From what I’ve read using :colletion instead of a loop with :object should help to improve those times however I’m not sure how I can wrap each instance of the widget in an LI if I use :collection. Not ever place the widget is used on the site is in a list so it doesn’t make sense to include the LI in the widget code.
I could include the widget code directly in the loop rather than in a partial however I don’t want to have to make code updates in multiple places.
Any other ideas to improve performance would be appreciated!
Give
content_taga try: