简体   繁体   English

从优化的应用中消除对require js的需求

[英]Eliminating need for require js from optimized app

I've built my app using require.js in order to keep everything modular. 我已经使用require.js构建了我的应用程序,以使所有模块保持模块化。 Having finished it turns out that require.js itself is bigger than my optimised app code. 完成后,事实证明require.js本身比我优化的应用程序代码更大。 Is there some way I can get r.js to optimise in such a way that I don't need to include require.js in the final page (eg replacing all my define calls with direct definition of properties on a namespace object, with the whole thing wrapped in a closure). 有什么方法可以使r.js进行优化,而无需在最后一页中包含require.js(例如,用命名空间对象上的属性的直接定义替换所有我的define调用,整个东西都包裹在一个封闭中)。

I'm only using define() - never require() , if that makes a difference..? 我只使用define() -从不require() ,如果有所不同..?

You still need an AMD loader but you can switch to a much lighter one, such as almond . 您仍然需要AMD装载机,但可以切换到轻得多的装载机,例如almond almond is around 1 kilobyte when minified and gzipped. 杏仁经过压缩和压缩后约为1 KB。

From the FAQ : 常见问题解答

almond is an AMD API shim that is very small, so it can be used in place of require.js when all of your modules are built into one file using the RequireJS optimizer. almond是非常小的AMD API填充程序,因此,当使用RequireJS优化器将所有模块构建到一个文件中时,它可以代替require.js使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM