在一个项目中使用多个Javascript框架? [英] Using multiple Javascript frameworks in a project?

查看:52
本文介绍了在一个项目中使用多个Javascript框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目中拥有多个框架是好是好,还是不好,因为它变得凌乱(=一团糟),并且加载时间可能更长.大约100 K真的重要吗?还是应该坚持?

Is it good or okay to have several frameworks in a project, or is it bad because it gets cluttered (= a mess), and the loading times maybe get's longer. Does some 100 K matter really? Or should you stick with one?

推荐答案

通常最好选择一件东西并坚持使用,原因有很多:

It's generally better to pick one thing and stick with it, for a number of reasons:

  • 更少的依赖项.
  • 降低复杂性.
  • 易于维护.
  • 更快的加载时间.
  • 不存在依赖关系冲突的可能性(即,如果您只有一个,则jQuery不能与您的其他Javascript框架冲突).
  • 缩短调试时间.

这几天确实增加了大约5万英镑可能并不会杀死任何个人网站或博客.当您扩展到更大的尺寸时,好处就来了,而所有这些额外的5万次点击都将蚕食您的底线.但是,即使您只是在一个小型站点上执行此操作,通过快速解决问题来节省理智也将很值得.

It's true that an extra ~50k these days probably isn't going to kill anybody for a personal site or blog. The benefit comes when you scale to larger sizes, and all those extra 50k hits are eating into your bottom line. But even if you're just doing this for a small site, the savings on your sanity from figuring out problems quicker will easily be worth it.

也就是说,如果您只需要一个Javascript框架的特定部分的一部分,通常会将较大的部分拆分为逻辑块,以便您可以只使用所需的部分而不是整个框架.如今,大多数功能已经足够丰富,如果框架X具有您想要的功能,但是您正在使用框架Y,则几乎可以直接将该功能的源代码映射到框架Y中.

That said, if you just need one part of a specific piece of a Javascript framework, the larger ones are often split into logical chunks, so that you can just take the piece you need rather than the entire framework. Most are rich enough these days that if framework X has a feature you want, but you're using framework Y, you can pretty much just map the source code for that feature directly into framework Y.

这篇关于在一个项目中使用多个Javascript框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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