JavaScript代码编写尝试使用Vanilla JS 或者Jquery插件
From Here: http://vanilla-js.com/
Introduction
The Vanilla JS team maintains every byte of code in the framework and works hard each day to make sure it is small and intuitive. Who's using Vanilla JS? Glad you asked! Here are a few:
- YouTube
- Yahoo
- Wikipedia
- Windows Live
- Amazon
- MSN
- eBay
- Microsoft
- Tumblr
- Apple
- PayPal
- Netflix
- Stack Overflow
In fact, Vanilla JS is already used on more websites than jQuery, Prototype JS, MooTools, YUI, and Google Web Toolkit - combined.
Download
Ready to try Vanilla JS? Choose exactly what you need!
Options
Minify Source CodeProduce UTF8 OutputUse "CRLF" line breaks (Windows)
Testimonials
Vanilla JS makes everything an object, which is very convenient for OO JS applications.
Getting Started
The Vanilla JS team takes pride in the fact that it is the most lightweight framework available anywhere; using our production-quality deployment strategy, your users' browsers will have Vanilla JS loaded into memory before it even requests your site.
To use Vanilla JS, just put the following code anywhere in your application's HTML:
- <script src="path/to/vanilla.js"></script>
When you're ready to move your application to a production deployment, switch to the much faster method:
That's right - no code at all. Vanilla JS is so popular that browsers have been automatically loading it for over a decade.
Speed Comparison
Here are a few examples of just how fast Vanilla JS really is:
Retrieve DOM element by ID
| Code | ops / sec | |
|---|---|---|
| Vanilla JS | document.getElementById('test-table'); |
12,137,211
|
| Dojo | dojo.byId('test-table'); |
5,443,343
|
| Prototype JS | $('test-table') |
2,940,734
|
| Ext JS | delete Ext.elCache['test-table']; Ext.get('test-table'); |
997,562
|
| jQuery | $jq('#test-table'); |
350,557
|
| YUI | YAHOO.util.Dom.get('test-table'); |
326,534
|
| MooTools | document.id('test-table'); |
78,802
|
Retrieve DOM elements by tag name
| Code | ops / sec | |
|---|---|---|
| Vanilla JS | document.getElementsByTagName("span"); |
8,280,893
|
| Prototype JS | Prototype.Selector.select('span', document); |
62,872
|
| YUI | YAHOO.util.Dom.getElementsBy(function(){return true;},'span'); |
48,545
|
| Ext JS | Ext.query('span'); |
46,915
|
| jQuery | $jq('span'); |
19,449
|
| Dojo | dojo.query('span'); |
10,335
|
| MooTools | Slick.search(document, 'span', new Elements); |
5,457
|
Code Examples
Here are some examples of common tasks in Vanilla JS and other frameworks:
Fade an element out and then remove it
| Vanilla JS | var s = document.getElementById('thing').style; s.opacity = 1; (function fade(){(s.opacity-=.1)<0?s.display="none":setTimeout(fade,40)})(); |
|---|---|
| jQuery | <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $('#thing').fadeOut(); </script> |
Make an AJAX call
| Vanilla JS |
var r = new XMLHttpRequest(); |
|---|---|
| jQuery |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$.ajax({
type: 'POST',
url: "path/to/api",
data: "banana=yellow",
success: function (data) {
alert("Success: " + data);
}
});
</script>
|
Further Reading
For more information about Vanilla JS:
- check out the Vanilla JS documentation
- read some books on Vanilla JS
- or try out one of the many Vanilla JS plugins.
JavaScript代码编写尝试使用Vanilla JS 或者Jquery插件的更多相关文章
- 纯javascript代码编写计算器程序
今天来分享一下用纯javascript代码编写的一个计算器程序,很多行业都能用到这个程序,例如做装修预算.贷款利率等等. 首先来看一下完成后的效果: 具体代码如下:(关注我的博客,及时获取最新WEB前 ...
- 如何为javascript代码编写注释以支持智能感知
在使用Visual Studio做开发的时候,智能感知是非常方便的.从VS2008开始,提供了对javascript的智能感知支持.例如 上述代码中,我们先用document对象的getElement ...
- 编写可维护的javascript代码---开篇(介绍自动报错的插件)
文章开篇主要推荐了2款检测编程风格的工具: JSLint和JSHint: jsLint是由Douglas Crockford创建的.这是一个通用的javascript代码质量检测工具,最开始JSLin ...
- 最简单的原生js和jquery插件封装
最近在开发过程中用别人的插件有问题,所以研究了一下,怎么封装自己的插件. 如果是制作jquery插件的话.就将下面的extend方法换成 $.extend 方法,其他都一样. 总结一下实现原理: 将 ...
- JS:jquery插件表格单元格合并.
公司需要用到单元格合并,于是动手封装了一个简单的jquery插件,封装的函数是直接写好转的,请多多提意见看代码是否有优化的地方..... 截图: 代码: /* * mergeTable 0.1 * C ...
- 区分PC端与移动端代码,涵盖C#、JS、JQuery、webconfig
1)C#区分PC端或移动端 using System.Text.RegularExpressions string u = Request.ServerVariables["HTTP_USE ...
- jsTree 是一个基于Javascript,支持多浏览器的Tree view jQuery插件。
https://www.jstree.com/ 之前给大家介绍两种浮动闭合的办法CSS清除浮动 万能float闭合,得 http://www.daqianduan.com/3606.html
- 编写可维护的js代码
在工作中,制定一套统一的编码风格,可以提高开发效率,维护起来的也要容易很多,也能避免一些不必要的错误出现. 项目中常用的检查编码风格的工具JSLint.JSHint.JSCS.ESLint,,在这呢, ...
- Javascript模块化编程之路——(require.js)
转自:http://www.ruanyifeng.com/blog/2012/10/javascript_module.html Javascript模块化编程(一):模块的写法 随着网站逐渐变成&q ...
随机推荐
- python实现zabbix_sender的socket通信代码样例
sk = socket.socket() sk.connect(self.ip_port) sk.settimeout(5) sk.sendall(b'ZBXD\x01') sk.sendall(b' ...
- python列表推导和字典推导
代码如下: list = ['aaa','bbb','ccc','ddd'] dict = {key:value for value,key in enumerate(list)} print(dic ...
- 整数v,从高位到低位,取c位数,得到最大数 (其中:v>=10^c)
题目如上,例子v=22312324,c=3,求得最大数为334. 用自己的想法实现了一遍,如果你有更好的方法的话,欢迎不吝赐教. 我的思路是,先将整数v按位存入一个数组,数组低位为整数高位,如num[ ...
- Data Mining 概念
数据挖掘概念: 数据挖掘是在大型数据库中.自动的发现有用信息的过程. 然. 这个有用只是一个感性的东西.比如我们从表中索引一行数据.这个算不上数据挖掘.因为它依赖的是数据的明显特征. 数据挖掘基本步骤 ...
- 阅读express的感悟
在github上看了半天的源码,也是云里雾里,勉强也算看完了,通过查看很多人的讲解也方便了我的理解,今天记录下来,也算是做个笔记. 进入express的源码文件里我们可以看到8个文件:middlewa ...
- Inno Setup 网页显示插件 webctrl (V2.1 版本)
原文 http://restools.hanzify.org/article.asp?id=90 Inno Setup网页显示插件 webctrl能够显示所有 IE 中能够显示的东西. 引用内容 ; ...
- 在IE浏览器中iframe跨域访问cookie/session丢失的解决办法
单点登录需要在需要进入的子系统B中添加一个类,用于接收A系统传过来的参数: @Action(value = "outerLogin", results = { @Result(na ...
- (一)boost库之日期、时间
(一)boost库之日期.时间 一.计时器 计时器,通常在一个项目中统计一个函数的执行时间是非常实用的. #include <boost/timer.hpp> void PrintU ...
- 命令行解释器(shell)
unix> ./hello hello world unix> ll 显示当前目录下文件信息. shell为命令行解释器,第一个单词可以是内置的外壳命令,也可以是一个可执行文件名.
- 北京西服定做_衬衫定制_关于我们_Dimoon TLR.
北京西服定做_衬衫定制_关于我们_Dimoon TLR.