简体   繁体   English

使用requirejs扩展Web应用程序

[英]Scaling web applications with requirejs

I am building a js application based on RequireJs. 我正在构建一个基于RequireJs的js应用程序。 Everything is working fine except one thing, after compiling it with r.js application is around 2.5Mb. 一切正常,除了一件事,用r.js应用程序编译后大约是2.5Mb。 And it does not have yet all the functionality available, i mean there is still room to work inside. 它还没有所有可用的功能,我的意思是仍有工作空间。 And i am afraid that the compiled js file will be over 5Mb and mobile users might face some challenges on slow internet connection. 我担心编译的js文件将超过5Mb,移动用户可能会遇到一些慢速互联网连接的挑战。

So my question is: 所以我的问题是:

Is this normal to have such big files on very large js applications? 在非常大的js应用程序上有这么大的文件这是正常的吗? Or should i split it on smaller applications/modules? 或者我应该将它拆分为较小的应用程序/模块?

I would really recommend splitting that large file in modules/files. 我真的建议在模块/文件中拆分那个大文件。 Data transfer is not much of an issue nowadays but still, this could mean some really performance issues for some users that still dont have access to fast networks. 数据传输现在不是一个大问题,但是,这可能意味着一些仍然无法访问快速网络的用户的性能问题。 You should check what resources you need in order to bootstrap your app and have them loaded first, and everything else should be loaded on demand as you need them. 您应该检查您需要哪些资源来引导您的应用并首先加载它们,然后根据您的需要加载其他所有资源。 Requirejs is a really good approach. Requirejs是一个非常好的方法。

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

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