Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stylesheet async with rails

I want to load my javascripts and stylesheets async to have a better loading performance; with javascript I know I can load the javascripts async with:

javascript_include_tag "application", :async => true

and it works for the javascripts. But is this isn't possible with the stylesheet_link_tag like:

stylesheet_link_tag "application, :media => "all", :async => true

also is this the "nice" way to do this? thanks

I'm using rails 3.2.12 and ruby 1.8.7

like image 370
joseramonc Avatar asked Feb 12 '14 20:02

joseramonc


1 Answers

The async attribute is not available on the <link> tag. It is only used for asynchronously downloading external script resources.

The idea is that you don't want to delay the CSS download because it is needed to render the page whereas javascript can often be downloaded at the same time as the html and executed when it has completed.

It doesn't make sense for there to be an async option for external css resources.

like image 52
iNulty Avatar answered Oct 22 '22 22:10

iNulty