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
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
Share Improve this question edited Feb 18, 2014 at 19:49 joseramonc asked Feb 12, 2014 at 20:11 joseramoncjoseramonc 1,9312 gold badges21 silver badges40 bronze badges 3- Ruby 1.8.7 reached End of Life some time ago - you should really look at upgrading. – sevenseacat Commented Feb 13, 2014 at 7:10
- @sevenseacat any way to do it in ruby 1.9.2 or 2.0? – joseramonc Commented Feb 13, 2014 at 7:13
- the problem is unrelated to the version of Ruby, I'm simply suggesting that you should really upgrade your app to a newer version. – sevenseacat Commented Feb 13, 2014 at 7:14
1 Answer
Reset to default 8The 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 pleted.
It doesn't make sense for there to be an async option for external css resources.