From Here: http://vanilla-js.com/

Vanilla JS is a fast, lightweight, cross-platform frameworkfor building incredible, powerful JavaScript applications.

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:

  • Facebook
  • Google
  • YouTube
  • Yahoo
  • Wikipedia
  • Windows Live
  • Twitter
  • Amazon
  • LinkedIn
  • MSN
  • eBay
  • Microsoft
  • Tumblr
  • Apple
  • Pinterest
  • PayPal
  • Reddit
  • 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!

 Core FunctionalityDOM (Traversal / Selectors)Prototype-based Object SystemAJAXAnimationsEvent SystemRegular ExpressionsFunctions as first-class objectsClosuresMath LibraryArray LibraryString Library

Options

Minify Source CodeProduce UTF8 OutputUse "CRLF" line breaks (Windows)

Final size: 0 bytes uncompressed, 25 bytes gzipped.  Show human-readable sizes

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:

  1. <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:

  1.  

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(); 
r.open("POST", "path/to/api", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
alert("Success: " + r.responseText); };
r.send("banana=yellow");
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:

JavaScript代码编写尝试使用Vanilla JS 或者Jquery插件的更多相关文章

  1. 纯javascript代码编写计算器程序

    今天来分享一下用纯javascript代码编写的一个计算器程序,很多行业都能用到这个程序,例如做装修预算.贷款利率等等. 首先来看一下完成后的效果: 具体代码如下:(关注我的博客,及时获取最新WEB前 ...

  2. 如何为javascript代码编写注释以支持智能感知

    在使用Visual Studio做开发的时候,智能感知是非常方便的.从VS2008开始,提供了对javascript的智能感知支持.例如 上述代码中,我们先用document对象的getElement ...

  3. 编写可维护的javascript代码---开篇(介绍自动报错的插件)

    文章开篇主要推荐了2款检测编程风格的工具: JSLint和JSHint: jsLint是由Douglas Crockford创建的.这是一个通用的javascript代码质量检测工具,最开始JSLin ...

  4. 最简单的原生js和jquery插件封装

    最近在开发过程中用别人的插件有问题,所以研究了一下,怎么封装自己的插件. 如果是制作jquery插件的话.就将下面的extend方法换成  $.extend 方法,其他都一样. 总结一下实现原理: 将 ...

  5. JS:jquery插件表格单元格合并.

    公司需要用到单元格合并,于是动手封装了一个简单的jquery插件,封装的函数是直接写好转的,请多多提意见看代码是否有优化的地方..... 截图: 代码: /* * mergeTable 0.1 * C ...

  6. 区分PC端与移动端代码,涵盖C#、JS、JQuery、webconfig

    1)C#区分PC端或移动端 using System.Text.RegularExpressions string u = Request.ServerVariables["HTTP_USE ...

  7. jsTree 是一个基于Javascript,支持多浏览器的Tree view jQuery插件。

    https://www.jstree.com/ 之前给大家介绍两种浮动闭合的办法CSS清除浮动 万能float闭合,得 http://www.daqianduan.com/3606.html

  8. 编写可维护的js代码

    在工作中,制定一套统一的编码风格,可以提高开发效率,维护起来的也要容易很多,也能避免一些不必要的错误出现. 项目中常用的检查编码风格的工具JSLint.JSHint.JSCS.ESLint,,在这呢, ...

  9. Javascript模块化编程之路——(require.js)

    转自:http://www.ruanyifeng.com/blog/2012/10/javascript_module.html Javascript模块化编程(一):模块的写法 随着网站逐渐变成&q ...

随机推荐

  1. Kali Linux 新手折腾笔记

    http://defcon.cn/1618.html 2014年09月29日 渗透测试 暂无评论 阅读 55,052 次   最近在折腾Kali Linux 顺便做一简单整理,至于安装就不再多扯了,估 ...

  2. 通过Wmi实现Hyper-V远程管理(一)

    最近公司需要做Hyper-V的远程管理,在现有产品基础上扩展对Hyper V的管理,实现远程开关机.远程开启虚拟机会话,其他内容可查看MSDN中有对Hyper-V的描述和相关实例代码. Wmi操作hy ...

  3. 串口调试工具(Python2.7+pyserial+Tkinter)

    需要与串口设备进行通讯,那么一个调试工具是必须的. 根据我自己的需要,写了个简易版本的串口调试工具: 预览图: ====================== 项目结构: COM --SerialHel ...

  4. C++ 前置声明 和 包含头文件 如何选择

    假设有一个Date类 Date.h class Date { private: int year, month, day; }; 如果有个Task类的定义要用到Date类,有两种写法 其一 Task1 ...

  5. 一道C语言面试题:写一个宏,将16位的整数转为Big Endian

    题目:输入16位整数x,如0x1234,将其转为Big Endian格式再输出,此例为输出 0x3412 来源:某500强企业面试题目 思路:将x左移8位得到a,将x右移8位得到b,a+b即为所得 / ...

  6. SD卡在单片机上的应用

    (1)SD卡的引脚定义:  SD卡SPI模式下与单片机的连接图: 注意:SPI模式时,这些信号需要在主机端用10~100K欧的电阻上拉.      SD卡支持两种总线方式:SD方式与SPI方式.    ...

  7. the first has precedence, perhaps you need a NameVirtualHost directive

    报错信息1: Starting httpd: [Fri May 19 11:49:42 2011] [warn] VirtualHost 127.0.0.1:80 overl aps with Vir ...

  8. uva11029 - Leading and Trailing

    题目: 求n的k次方,然后将答案用前三位和最后三位表示. Sample Input 2 123456 1 123456 2 Sample Output 123...456 152...936 分析: ...

  9. How to Install/Deinstall Oracle Workspace Manager (文档 ID 263428.1)

    In this Document   Goal   Solution   References APPLIES TO: Workspace Manager - Version 9.0.1.0 to 1 ...

  10. 阿里大鱼短信接口整合Tp3.2.3开发整理

    阿里大鱼 http://www.alidayu.com/ 的短信接口总体是不错的,别安驹个人认为不管是从性价比还是稳定性上都是跟同类的短信接口好些,毕竟是大公司的东西不会差到哪去.下面把之前开发的短信 ...