gpt4 book ai didi

javascript - 使用 Rails 3.1 Assets 管道将 Javascript 放在文件末尾

转载 作者:行者123 更新时间:2023-11-30 13:27:16 24 4
gpt4 key购买 nike

有时在重度客户端 Javascript 中,我们将标记放在 HTML 文件的末尾,以便先显示内容,然后再加载 Javascript。

是否可以使用 Rails 3.1 Assets 管道来做到这一点?

编辑:

<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>

最佳答案

是的,您可以在 Rails 3.1 中做到这一点——在 View /布局中放置 javascript_include_tag 行的位置没有任何区别(就 Rails 而言)。

关于javascript - 使用 Rails 3.1 Assets 管道将 Javascript 放在文件末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8038484/

24 4 0