I just inherited some web pages which uses MooTools. I never used MooTools. Now I need to add some functions on the page, I wonder if it's a good idea to use jquery and mooTools on the same page?
我刚刚继承了一些使用MooTools的网页。我从未使用过MooTools。现在我需要在页面上添加一些函数,我想知道在同一页面上使用jquery和mooTools是个好主意吗?
Basically, I have 3 options,
基本上,我有3个选项,
将页面转换为JQuery,我必须学习MooTools才能做到这一点。
在MooTools中编写新功能。我必须学习更多的MooTools来实现这一目标。
在页面上同时使用两者。
Your opinion will be appreciated.
您的意见将不胜感激。
46
Opinion: Learn MooTools and then move on with it. Sounds like a great opportunity to learn something new. Why introduce an entirely new library with addition js bloat if you don't need to. If it'll solve the problem you're golden.
意见:学习MooTools,然后继续学习。听起来像学习新事物的好机会。如果你不需要,为什么要引入一个带有附加js膨胀的全新库。如果它能解决问题你就是金色的。
16
MooTools is a perfectly solid and acceptable Javascript library and I'd recommend you add it to your list of known technologies rather than tear it out and replace with JQuery. Mixing the two is not a good idea as you're likely to encounter obscure difficult to debug conflicts.
MooTools是一个完全可靠且可接受的Javascript库,我建议您将其添加到已知技术列表中,而不是将其删除并替换为JQuery。混合这两者并不是一个好主意,因为您可能会遇到模糊的难以调试的冲突。
JQuery has had all the press of late, but it's by no means cut and dried that it beats every other library hands-down. Far from it. You might even find you prefer MooTools :-)
JQuery最近收到了所有的报道,但它并没有削减和干涸,它击败了其他所有图书馆。离得很远。您甚至可能会发现您更喜欢MooTools :-)
ADDED: For what it's worth my personal experience is that MooTools seems to play alongside other Javascript code more nicely than jQuery. I've been handling several sites of late which have mixed in MooTools with various other pieces of Javascript for different effects/functionality and it's all seemed to play along together with minimal issues. OTOH pages that use jQuery tend to use jQuery versions of everything. YMMV of course.
添加:值得我个人经验的是,MooTools似乎与jQuery相比更好地与其他Javascript代码一起使用。我一直在处理几个已经混合了MooTools的网站,其中包含各种其他Javascript的不同效果/功能,它们似乎与最小的问题一起发挥。使用jQuery的OTOH页面倾向于使用jQuery版本的所有内容。 YMMV当然。
7
Personally, I'd recommend not using both, as there are strange conflicts, even with jQuery.noConflict()
. Go with one or the other.
就个人而言,我建议不要同时使用两者,因为即使使用jQuery.noConflict()也存在奇怪的冲突。一个或另一个去。
If you do end up using both, be sure to use jQuery.noConflict()
to ensure that using the $
doesn't conflict.
如果你最终使用两者,请务必使用jQuery.noConflict()以确保使用$不会发生冲突。
Using jQuery with Other Libraries
将jQuery与其他库一起使用
7
i'd say, depends on how the code is structured and what you need to do. mootools does render itself to easy refactoring and extending (this is, after all, partly the reason it exists) but it takes a while to figure best practices and so forth.
我会说,取决于代码的结构以及您需要做什么。 mootools确实使自己易于重构和扩展(毕竟,这部分是它存在的原因)但是需要一段时间来计算最佳实践等等。
however, your learning curve from vanilla Javascript or jquery won't be too steep, especially so if all you care about is DOM mantipulation, event handling and effects. things get more interesting when you decide to write / extend mootools classes and venture into prototyping - but you may not have to do that...
然而,你的vanilla Javascript或jquery的学习曲线不会太陡峭,尤其如此,如果你关心的只是DOM的人为因素,事件处理和效果。当你决定编写/扩展mootools类并冒险进行原型设计时,事情变得更有趣 - 但你可能不必这样做......
there are some pretty good tutorials around for most things as well as some demos on doing things through jquery and mootools (equivalent ones). http://jqueryvsmootools.com/ is a good example on how the same task can be done through either one, i'd recommend reading it before deciding.
对于大多数事情都有一些非常好的教程,以及一些通过jquery和mootools(等效的)做事的演示。 http://jqueryvsmootools.com/是关于如何通过任何一个完成相同任务的一个很好的例子,我建议在决定之前阅读它。
whatever you decide, it is a bad practice to use two frameworks (when you can do without).
无论你决定什么,使用两个框架是不好的做法(当你没有框架时)。
6
It depends on how big a project it would be to convert to jQuery, how much of your job is maintaing these pages (vs other pages that already use jQuery), what the urgency is for your first set of changes, etc...
这取决于转换为jQuery的项目有多大,维护这些页面的工作量(与已经使用jQuery的其他页面相比),第一组更改的紧迫性等等......
It comes down to a cost comparison: how does the cost to your business to convert them to jQuery compare to the cost to the business for you to learn mooTools (and maybe keep both mootools and jquery in your head at the same time).
它归结为成本比较:您将业务转换为jQuery的成本与您学习mooTools的业务成本相比如何(并且可能同时保持mootools和jquery)。
The only thing I can say for sure is don't do option 3. This isn't necessarily because it you can't make it work (and there will be challenges), but because you'll have to learn mootools to properly maintain the pages anyway. Once you do that, you may as well just keep them mootools rather than re-write everything or try to mix frameworks.
我唯一可以肯定的是不做选项3.这不一定是因为你不能使它工作(并且会有挑战),但是因为你必须学习mootools来正确维护无论如何这些页面。一旦你这样做,你可能只是让他们保持mootools而不是重写所有内容或尝试混合框架。
Personally I'm inclined to say convert it jQuery, since I believe jQuery is eventually going to corner the market. The implication then is that it will convert to jQuery at some point, and so the long term costs to business are probably best optimized by doing the conversion earlier while there's less to convert and mootools is still relevant so you can easily get help with the conversion. But that's certainly arguable.
就个人而言,我倾向于将其转换为jQuery,因为我相信jQuery最终会在市场上占据一席之地。这意味着它将在某个时刻转换为jQuery,因此业务的长期成本可能最好通过更早地进行转换来优化,而转换的时间更少,并且mootools仍然相关,因此您可以轻松获得转换的帮助。但这肯定是有争议的。
4
jQuery and Mootools basics are close enough that moving from one to the other isn't much of a headache.
jQuery和Mootools的基础知识非常接近,从一个移动到另一个并不是一个令人头痛的问题。
Whenever I'm given the choice between the two, I lean towards Mootools - especially if I'm intending to do any sort of effects or animations. Mootools's base FX libraries are far more robust and generate better results cross-browser in my experience.
每当我在两者之间做出选择时,我倾向于Mootools - 特别是如果我打算做任何类型的效果或动画。根据我的经验,Mootools的基本FX库更加强大,并且可以跨浏览器生成更好的结果。
Like others have suggested, you could take this opportunity as a learning experience. If you're satisfied with jQuery and don't feel the need to learn another framework, port the code over. You can't really go wrong with either in the end.
像其他人建议的那样,你可以借此机会作为学习经历。如果您对jQuery感到满意并且不觉得需要学习另一个框架,请将代码移植到底。最后你不会真的出错。
3
Since you're more comfortable with jQuery, I would just call jQuery.noConflict();
first thing, and write the functions in jQuery. That is, of course, if time is a factor.
既然你对jQuery更熟悉,我只需要调用jQuery.noConflict();第一件事,并在jQuery中编写函数。当然,如果时间是一个因素。
2
There is a project that twists and prods Mootools to make it look like JQuery (a wolf in a sheep's clothing... or a golden coin painted to look like silver...)
有一个项目扭曲并刺激Mootools使它看起来像JQuery(穿着羊皮的狼......或者看起来像银色的金币......)
I certainly think you should learn Mootools, but that might help.
我当然认为你应该学习Mootools,但这可能有所帮助。
1
I agree with those that are in favor of learning mootols, but i think that is even better if your take that decision because you finally think that learning mootools worth it.
我赞同那些赞成学习mootols的人,但我认为如果你做出这个决定会更好,因为你最终认为学习mootools值得。
So i think it would be nice to have some research over mootools capabilities.
所以我认为对mootools功能进行一些研究会很好。
I like this articule about this subject. And I think it can be useful for those reading this thread.
我喜欢这个关于这个主题的关键词。我认为这对阅读这个帖子的人来说很有用。
http://jqueryvsmootools.com/index.html
0
I wrote a blog post about running the 2 side by side. http://chrisbarba.wordpress.com/2009/12/30/need-to-run-jq…s-side-by-side/
我写了一篇关于并排运行2的博客文章。 http://chrisbarba.wordpress.com/2009/12/30/need-to-run-jq...s-side-by-side/
I had no trouble getting it work in a SharePoint site. Chris
我在SharePoint网站上运行它没有任何问题。克里斯