Reputation: 11538
Sometimes in heavy client side Javascript we put the tags at the end of the HTML file so that the content is displayed first while Javascript is loaded afterwards.
Is it possible to do this using Rails 3.1 assets pipeline?
EDIT:
<html>
<head>
<%= javascript_include_tag "application" %>
</head>
<body>
<!-- all the page content goes here -->
<!-- we include these at the bottom to ensure the html loads first and the javascript is loaded afterwards. How can we achieve this through rails asset pipelining? -->
<script src="/some_other_assets/first_file.js"></script>
<script src="/some_other_assets/second_file.js"></script>
<script src="/some_other_assets/third_file.js"></script>
</body>
</html>
Upvotes: 1
Views: 3578
Reputation: 829
Not sure if you got the answer for this, but you can include multiple manifest files and set up which files you want at the bottom of the page.
In other words, I could create a footer.js manifest file, tell it to include the scripts you want, and then at the bottom of your view template, include it the same way you do your application.js file with the
<%= javascript_include_tag("footer") %>
tag.
You can read more here-
http://coderberry.me/blog/2012/04/24/asset-pipeline-for-dummies/
Upvotes: 1
Reputation: 80041
Yes, you can do this with Rails 3.1 — it doesn't make any difference (as far as Rails is concerned) where you put your javascript_include_tag
lines in your view/layout.
Upvotes: 2