Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于web端消除eval并保证效率的一点建议,以及相应写法的优化。 #81

Open
Gaubee opened this issue Jun 18, 2013 · 0 comments

Comments

@Gaubee
Copy link

Gaubee commented Jun 18, 2013

据我所测试,web端的document.write这个应该和直接引入<script >的效率无异把。
所以基于此处,我是建议之间编译整个脚本块,

//<script>
Wind(function(){//包裹整个代码域
  //可能而外需要做的就是判定Wind.compile是否在字符串中
  var hello = Wind.compile("async", function () {
    console.log("hello")
  };
})
//<script>

当然,如果真的是要预编译整个文档,我更推崇下面这种写法,更加优雅客观:

//<script>
Wind(function(){//包裹整个代码域
  //可能而外需要做的就是判定Wind.compile是否在字符串中
  var hello = function () {
    "using wind";
    console.log("hello")
  };
})
//<script>

这种写法就不用写一堆的判定了把,只要一些正则和字符串处理就OK了,更优雅的实现不是?@JeffreyZhao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant