# ng-staticize **Repository Path**: mirrors_ElemeFE/ng-staticize ## Basic Information - **Project Name**: ng-staticize - **Description**: Staticize your angular template. Zero watcher and fast as template engine. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-07-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Introduce ng-staticize 是一个把 Angular 模板静态化的 directive,使用之后 watcher 数量会显著降低,渲染速度(在数据量较大的情况下)在 IE8 上会有10-20x的性能提升。 你可以花几分钟查看 [这个例子](http://elemefe.github.io/ng-staticize/) 来体验一下 ng-staticize 带来的性能提升,在 IE8 或者 Firefox 下会看到更明显的性能提升。 从降低 Angular watcher 的角度来看,ng-staticize 是一个与 [bindonce](https://github.com/Pasvaz/bindonce) 类似的项目,区别在于 ng-staticize 无需改变模板中 directive 的定义。 从设计之初,ng-staticize 就存在以下缺陷,请知悉: 1. 应用 ng-staticize 的区域中不能使用 directive 兼容列表以外的 directive。 2. 渲染出的 DOM 不再动态,即在 Controller 中的数据变更后,应用了 ng-staticize 的区域不会重新渲染。不过你可以为 ng-staticize 指定一个表达式,在表达式变更后这个区域会重新渲染。 以下是 ng-staticize 适用场景: 1. 页面动态渲染比较少,类似于静态页面,只是使用了 Angular 的模板来描述数据绑定。 2. 页面中需要渲染的数据较多,需要做性能优化。 如果你对 ng-staticize 的实现细节感兴趣,你可以阅读 [这篇文档](HOW.MD)。 # Usage ## Install 如果你使用 Browerify 或者 Webpack,可以使用 npm 来安装 ng-staticize: ```Bash npm install ng-staticize —save ``` 如果没有使用 npm,则可以下载项目后,在项目中引用 dist 下的 ng-staticize.js。 ## Include ngStaticize ```JavaScript angular.module('demo', [ 'ngStaticize' ]); ``` ## Use 如果只是想把页面中的某一个页面中的某个区域进行静态化操作,只需要为这个区域的元素添加一个属性:ng-staticize。 ```HTML