Skip to content

Commit b8080b5

Browse files
author
zhangwentao
committed
update read
1 parent f423ba1 commit b8080b5

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
her-preprocessor-fispadaptor
2-
3-
一个兼容fisp项目的插件
4-
5-
============================
61
##使用方法##
72
###1.安装插件###
83
```
94
npm install her-preprocessor-fispadaptor -g
105
```
6+
117
###2.配置fis-conf###
128
```
139
fis.config.get('modules.preprocessor.tpl').unshift('fispadaptor')
@@ -30,9 +26,15 @@ fis.config.get('modules.preprocessor.tpl').unshift('fispadaptor')
3026

3127
###2.替换前端运行时框架###
3228

33-
前端运行时框架在static目录,其中bigpipe.js和amd.js是框架运行必须的代码,需要在`{html}`标签初始化,可以用inline的方式引入,例如:
29+
前端运行时框架在static目录,其中bigpipe.js和amd.js是框架运行必须的代码,需要在`{html}`标签初始化,可以先inline到lib.js,然后在`{html}`标签引入,例如:
3430

31+
```javascript
32+
// in lib.js
33+
__inline('bigpipe.js');
34+
__inline('amd.js');
35+
```
3536
```smarty
37+
// in tpl
3638
{strip}
3739
{html framework="common:static/lib.js" lang="zh-cn"}
3840
{head}
@@ -60,9 +62,45 @@ var $ = require('common:static/jquery.js');
6062
```
6163
$ her release -c
6264
```
63-
发布模块。至此你的模块已经可以run起来,你可以继续按下面的步骤就行性能优化。
65+
发布模块。至此你的模块已经可以run起来,你可以继续按下面的步骤进行性能优化。
66+
注意:
67+
`{script}`标签内的js执行是在包含它的pagelet load之后,所以不能在`{script}`使用`documet.write()`,如果一定要使用`documet.write()`,在`{pagelet}`外可以直接写`<script>`标签。`{pagelet}`中的内容都不是同步输出的,不能使用`documet.write()`
68+
6469

6570
###5.性能优化###
6671

72+
####5.1使用`{pagelet}`将页面分块([wiki](https://github.com/hao123-dev/her/wiki/03-01.Smarty%E6%A8%A1%E6%9D%BF))####
73+
74+
`{pagelet}`将页面分块,并收集其中的html、css、js。`{pagelet}`中的内容都通过js渲染。建议将非首屏内容都添加`{pagelet}`,异步渲染。
6775

76+
####5.2 非首屏内容使用bigrender####
77+
在pagelet加载之前用js阻止,并在需要的时候手动调用pagelet.load()加载pagelet,即可实现bigrender。
78+
79+
依赖bigRender.js、lazy.js和jquery
80+
```smarty
81+
{pagelet}
82+
...
83+
{script on="beforeload"}
84+
return !require('common:static/bigRender.js').add(this);
85+
{/script}
86+
...
87+
{/pagelet}
88+
```
89+
90+
####5.3 除框架js之外的所有业务js都使用require.defer([wiki](https://github.com/hao123-dev/her/wiki/03-02.Javascript))####
91+
92+
require.defer 会将模块的加载推迟到页面 onload 之后,以防止对首屏速度的影响。
93+
94+
###6.高级功能###
95+
96+
####6.1 Quickling局部刷新####
97+
98+
可以使用 BigPipe.fetch(pagelets[, url, cache]) 函数实现Quickling局部刷新。
99+
100+
同时我们也提供了 pageEmulator.js 监听a标签点击实现局部刷新
101+
```javascript
102+
require.defer('common:static/pageEmulator.js',function(emulator){
103+
emulator.start();
104+
});
105+
```
68106

0 commit comments

Comments
 (0)