title: Loading multiple images from S3 on a Rails 4 app: slow loading page
body: <p>I have an users index page that simply list users and show their avatars (uploaded on Amazon S3 with carrier wave and fog):</p>
  
  <p><strong>app/views/users/index.html.erb</strong></p>
  
  <pre><code>&lt;% @users.each do |user| %&gt;
      &lt;% if ! user.avatar_url.nil? &amp;&amp; user.avatar.file.exists? %&gt;
          &lt;div class=“avatar"&gt;
              &lt;%= link_to (image_tag user.avatar_url.to_s), user %&gt;
          &lt;/div&gt;
      ...
      &lt;% end %&gt;   
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>config/initializers/carrierwave.rb</strong></p>
  
  <pre><code>CarrierWave.configure do |config|
     config.fog_credentials = {
       :provider               =&gt; 'AWS',
       :aws_access_key_id      =&gt; ENV["AWS_ACCESS_KEY_ID"],
       :aws_secret_access_key  =&gt; ENV["AWS_SECRET_ACCESS_KEY"],
       :region                 =&gt; 'eu-west-1'                  # optional, defaults to 'us-east-1'
     }
     config.fog_directory  = ENV["AWS_S3_BUCKET"]                     # required
     config.fog_public     = true                                   # optional, defaults to true
  end
  </code></pre>
  
  <p>The index page is really slow to load, while getting all images.</p>
  
  <p>Is there a way to speedup page loading, maybe through a lazy load and an ajax request?</p>
  
  <p>Thank you for your help and time, and sorry for this newbie question.</p>
  
  <p>p.s. I would add that even when I load an user profile page sometimes it doesn't display any avatar (in that case, only if I reload page avatar is shown correctly)</p>