Plugins - Multi asset locations

StarAdd to favorites

This plugin helps you leverage a setting of action controller. asset_host. Normally in rails you have one location, and one location only for all of your assets, being images, stylesheet or javascripts. Since browsers usually have a limit of 2 downloading pipelines (http pipelining | http://en.wikipedia.org/wiki/HTTP_pipelining) per domain, it means that the more domains you serve your assets from, the more concurrent downloads you can have, the quicker the page download happens. Couple this technique with minizing and gzipping for maximum result.

Normally you can now set your ActionController::Base.asset_host to only one location by passing a string.

ActionController::Base.asset_host = "http://myasset.domain.com"

Once you do that your imagetag, includejavascripttag, stylesheetlink_tag are all served from that domain. (the default is an empty string)

With this plugin you can choose to pass either a string or a hash. The acceptable keys are :javascripts, :stylesheets and :images. You can pass either one or all of the keys.

For Ex.:

ActionController::Base.asset_host = {:images      => "http://images.domain.com",
                                     :javascripts => "http://javascripts.domain.com",
                                     :stylesheets => "http://stylesheets.domain.com"}

ActionController::Base.asset_host = {:stylesheets => "http://stylesheets.domain.com"}

to install run

ruby script/plugin install http://simple-rails-plugins.googlecode.com/svn/multi-asset-locations/

For more info on how to optimize your page load time, check out: http://www.die.net/musings/pageloadtime/

Diego Scataglini

http://jroller.com/page/dscataglini

http://simple-rails-plugins.googlecode.com/svn/multi-asset-locations/

Rails' (MIT)

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Assets

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?