javascript - 如果把angular.js放在body底部会遇到什么问题?

标签 javascript html angularjs performance nonblocking

关于 anguler official guide - bootstrap我阅读:

Place the script tag at the bottom of the page. Placing script tags at the end of the page improves app load time because the HTML loading is not blocked by loading of the angular.js script. You can get the latest bits from http://code.angularjs.org. Please don't link your production code to this URL, as it will expose a security hole on your site. For experimental development linking to our site is fine.

也在同一站点上 AngularJS ngCloack我阅读:

For the best result, the angular.js script must be loaded in the head section of the html document

我是angularjs的新手,我的问题是:

把angulas.js脚本放在body底部,让我的html非阻塞会遇到什么问题?我在哪里可以学习如何处理这个问题?谢谢大家!

最佳答案

主要问题是,如果您在底部加载脚本,那么要使 ng-cloak 正常工作,ng-cloak 类的 CSS 需要在顶部加载。

来自文档:

ngCloak works in cooperation with the following css rule embedded within angular.js and angular.min.js

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}

For the best result, the angular.js script must be loaded in the head section of the html document; alternatively, the css rule above must be included in the external stylesheet of the application.

-- AngularJS ng-cloak Directive API Reference

关于javascript - 如果把angular.js放在body底部会遇到什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35419075/

相关文章:

JavaScript 内联事件或事后添加事件

javascript - 删除所有按下的按键事件

javascript - 悬停时使用淡入淡出效果交换图像

plupload - 使用 Plupload 创建 AngularJS 指令

javascript - 使用来自 Javascript 的样式,从带有完成回调的内部指令触发 CSS 转换

javascript - JS中的罗马到整数为什么它只转换第一个字符

javascript - 在标签标签上使用 this.form.submit()

html - 我的响应式网站只能在某些设备上正常运行

javascript - 从选择选项中获取文本

javascript - Highcharts 的格式类别(x 轴)