将defer属性添加到javascript_include_tag Rails

将defer属性添加到javascript_include_tag Rails

问题描述:

是否可以使用Rails中的 javascript_include_tag 帮助器轻松地添加 defer 属性?

Is there some way to add the defer attribute easily using the javascript_include_tag helper in Rails?

即,有一些简单的方法可以转弯

I.e., is there some easy way to turn

<%= javascript_include_tag blah.js %>

<脚本延迟src = blah.js>< / script>

<%= javascript_include_tag "blah.js", :defer => "defer" %>

这将使您(开发中):

<script defer="defer" src="/assets/blah.js" type="text/javascript"></script>