【发布时间】:2015-09-04 02:48:47
【问题描述】:
我一直在构建一个应用程序,随着它的发展,<script> 标记也在index.html 中增长
index.html
<html>
<head></head>
<body>
<script src="angular.js"></script>
<script src="a.js"></script>
<script src="b.js"></script>
...
</body>
</html>
是否可以将所有这些<script> 包含到外部html 中,然后将其加载到index.html 中以使用它?像这样。
index.html
<html>
<head></head>
<body>
<script src="angular.js"></script>
[**Include jsInclude.html here**]
</body>
</html>
jsIncude.html
<script src="a.js"></script>
<script src="b.js"></script>
...
如果是这样,执行此类任务的正确方法是什么?
我在网上看到我可以使用 Grunt 或 RequireJS 来动态加载 JS 文件。
但是,我希望避免延迟加载,我想在启动时一次加载所有 JS 文件。
使用 RequireJS 或 Grunt 能做到这一点吗?或者有其他方法可以实现吗?
【问题讨论】:
标签: javascript html angularjs gruntjs requirejs