如何内联GAS库以加快脚本运行速度? [英] How to inline a GAS library to speed up script?

查看:56
本文介绍了如何内联GAS库以加快脚本运行速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

库的文档指出,应避免使用它们以加快脚本速度.有没有内联库的方法?我认为是否应该有办法提供这些资源?只需将库的源复制并粘贴到我的主脚本中即可吗?

The documentation for libraries states that they should be avoided in order to speed up the script. Is there a way to inline a library? I assume that there should be a way if the sources are available? Will just copy&pasting the sources of the library into my main script work?

推荐答案

复制'n粘贴应该起作用,因为您没有任何名称冲突.但是您必须重命名对库的所有调用,以删除库名称.

Copy 'n paste should work, given you don't have any name conflicts. But you'll have to rename all the calls to your library removing the library name.

可能可以创建一个构造函数来使名称空间保持完全相同.因此,您可以使用库或粘贴其代码而无需更改脚本的其余部分.

It's probably possible to create a constructor function to keep the namespace exactly the same. So you could you use the library or paste its code without changing the rest of the script.

无论如何,我认为文档对于不使用库的这种速度改进"有点苛刻.并不是说您的脚本在没有库的情况下运行速度会更快,而加载所需的时间会少一点.我认为这仅在您编写插件或带有大量UI交互的大量使用脚本等情况下才有意义.

Anyway, I think the documentation is a little harsh about this "speed improvement" of not using libraries. It's not that your script will run faster without a library, it'll just take a little less time to load. I think this is only relevant to do if you're writing addons or some massively used script with lots of UI interactions, etc.

这篇关于如何内联GAS库以加快脚本运行速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆