Prototype与JQuery对比

解道jdon 2021-05-04 14:49:31
Jquery prototype 技术开发 解道jdon


从时间上看,Prototype.js比Jquery早,国内占主流的是Jquery,个人认为可能是与国内AJAX比国外要落后一点,当然选择比较后出来、比较新的Jquery。

我个人是先从prototype.js入手,包括JiveJdon3.6版本都是基于它的,Jquery也一直关注,发现两者语法比较接近,prototype.js更接近Javascript风格,而Jquery设计上要简洁。

国外2007年有一篇文章对jQuery和Prototype做了比较:

Why I moved from Prototype to jQuery:

http://www.quarkruby.com/2007/11/6/why-i-moved-from-prototype-to-jquery

我认为JQuery主要优点是:Jquery是Behavior driven development (BDD)行为驱动开发。使用JQuery可以将html元素的行为从html中分离出来,实现所谓MVC J的模式,View是html,而J是Jquery.

至于文中提到的其他Jquery优点,prototype.js也有,比如Chain:

Jquery:

$("div.message").show()

.append("<p>Action has been executed successfully")

.addClass("flash");

prototype:

$$('input.date')

.invoke('observe', 'focus', onFocus)

.invoke('observe', 'blur', onBlur)

chain用法虽然简单,但不容易懂。

在下面这篇文章中,作者指出如何更加精炼简单地使用Prototype:

http://thinkweb2.com/projects/prototype-checklist/

比如常见的AJAX语法:

不带参数:new Ajax.Request('blah.php')

带参数:new Ajax.Request('ninja.php', {

parameters: {

weapon1: 'foo',

weapon2: 'bar'

}

})

获得某个字段的值:var woot = $F('bar')

修改某个字段的值:$('coolestWidgetEver').update('some nifty content')

设置CSS:

$('footer').setStyle({

height: '100px',

background: '#ffc'

})

最著名的争论是2007年的Prototype and jQuery: A code comparison

http://ajaxian.com/archives/prototype-and-jquery-a-code-comparison

使用PPT将两者做比较,讨论者无数。

不过,Prototype 有一个著名的windows效果简称PWC(Prototype Window Class):

http://prototype-window.xilinus.com/

至今没有在Jquery中发现类似替代,特别是这个页面的效果:http://prototype-window.xilinus.com/PWC-OS/index.html

号称可以替代PWC的JqModel:

http://dev.iceburg.net/jquery/jqModal/#examples

窗口效果比PWC要差多,PWC简直可以媲美Windows桌面效果,本论坛就是用的PWC效果。

有人说:基于Prototype更适合做一些应用框架库;而Jquery则是直接面向应用的,比较赞同。

[该贴被banq于2009-08-12 14:44修改过]

版权声明
本文为[解道jdon]所创,转载请带上原文链接,感谢
https://www.jdon.com/36786

  1. Two way linked list: I'm no longer one-way driving
  2. Vue event and form processing
  3. Reactive TraderCloud实时外汇开源交易平台
  4. Reactive tradercloud real time foreign exchange open source trading platform
  5. Node.js REST API的10个最佳实践
  6. Ten best practices of node.js rest API
  7. Fiddler advanced usage
  8. Process from Vue template to render
  9. Promise up (asynchronous or synchronous)
  10. Principle and implementation of promise
  11. Vs code plug in sharing - run code
  12. Vue practical notes (1) introduction of Ant Design
  13. Vue actual combat notes (2) introduction of element plus
  14. Introduction to webpack
  15. Webpack construction process
  16. Vue notes
  17. The experience and lessons of moving from ruby megalith architecture to go microservice
  18. Using leancloud to add artitalk module to hexo blog
  19. Implementation of chrome request filtering extension
  20. Detailed introduction of beer import declaration elements and label quarantine [import knowledge]
  21. Gallop workflow engine design series 01 process element design
  22. VUE移动端音乐APP学习【十六】:播放器歌词显示开发
  23. Vue Mobile Music App learning [16]: player lyrics display development
  24. jquery cookie
  25. jquery cookie
  26. 体面编码之JavaScript
  27. JavaScript for decent coding
  28. React17 系统精讲 结合TS打造旅游电商平台
  29. React17 system combined with TS to build tourism e-commerce platform
  30. 2021-05-04 hot news
  31. HttpSession对象与Cooike的关系 以及 Cookie对象构造函数问题
  32. gRPC-Web:替代REST的gRPC的Javascript库包
  33. The relationship between httpsession object and cooike and the construction of cookie object
  34. Grpc Web: a JavaScript library package to replace rest grpc
  35. Building reactive rest API with Java - kalpa Senanayake
  36. PDF转HTML工具——用springboot包装pdf2htmlEX命令行工具
  37. Pdf to HTML tool -- Wrapping pdf2htmlex command line tool with springboot
  38. PDF转HTML工具——用springboot包装pdf2htmlEX命令行工具
  39. Pdf to HTML tool -- Wrapping pdf2htmlex command line tool with springboot
  40. Vue.js比jQuery更容易学习
  41. Node.js的Reactor模式 与异步编程
  42. Vue. JS is easier to learn than jQuery
  43. Reactor mode of node.js and asynchronous programming
  44. 详解JavaScript中的正则表达式
  45. Explain regular expressions in JavaScript
  46. 详解JavaScript中的正则表达式
  47. Explain regular expressions in JavaScript
  48. JS: closure
  49. Write your own promise in promises / A + specification
  50. Analysis of the core mechanism of webpack from loader, plugin to egg
  51. On the import and export of webpack
  52. Interpretation of lodash source code (2)
  53. Hexo series (5) writing articles
  54. 有人用过JMeter或用HttpUnit写过测试吗????
  55. Has anyone ever used JMeter or written tests in httpUnit????
  56. JavaScript异步编程4——Promise错误处理
  57. Leetcode 1846. Reduce and rearrange the largest element of an array
  58. JavaScript asynchronous programming 4 -- promise error handling
  59. SQLite是一种经典的无服务器Serverless
  60. 通过Spring Boot Webflux实现Reactor Kafka