Skip to content

Instantly share code, notes, and snippets.

var _nodeUnique = function (nodeArray) {
var a = -1, len = nodeArray.length, b = -1, ret = new Array();
while (++a < len) {
while (++b < len && nodeArray[b] === nodeArray[a])
;
ret[b] = nodeArray[a];
}
var i,n=1000000;
var a="123";
var b=Object(a);
console.time("Primitive.charAt");
i=n;
while(i--)
a.charAt(0);
console.timeEnd("Primitive.charAt");
var
parseAcceptRE = new RegExp(/[{}\[\]:,]+|\"([^\\\"]*?\\.)*[^\"]*?\"|[+\-]?\d+(?:\.\d+)?(?:[eE][+\-]?\d+)?|true|false|null|\s+/g),
// var name at begin
// keywords, which can be written space separeted
// specific keywords
// operator and var name or object
// property access (but not number point delimiter)
// property access via square bracket (but not array declaration)
unsafeCharsRE = new RegExp(/^[a-zA-Z_\$\/]|var|new|instanceof|var|function|typeof|(?![\[,:]\[)[\+\-\*\/%\^&\|~\!\=<>\:,\[\(]\s*[a-zA-Z_\$\/\[]|\.[a-zA-Z_\$]|[\w\$\/\)\]]\s*\[/);
/* tnx @kangax for idea */
var i, n = 400000,
_fn = function(){}, that = {}, args = [];
console.time("call");
i = n; while(i--)
{
_fn.call(that);
}
// ==UserScript==
// @name 404cache
// @author Bga
// @version 0.11
// @description improve 404 default opera page by adding links to google and yandex cache
// ==/UserScript==
document.addEventListener("DOMContentLoaded",function(){
var $d = document, $h, v, vs, s, cs, c;
// tnx http://4umi.com/web/javascript/optimize.php for idea, but while(i--) the best :) (except opera :/)
var _fn = function(){};
var i, n=30, j, m = 100000;
console.time("1");
i = n; while(i--)
{
for( j = 0; j < m; j++ ) _fn();
}
var i,n=3000, j;
var a=document.getElementsByTagName('li'), m = a.length, v;
for(j = 0 ; j < m ; ++j)
a[j].b = {};
console.time("1");
for(i = 0 ; i < n ; ++i)
for(j = 0 ; j < m ; ++j)
/* MODIFY PROTOTYPE */
var _fn=function(){};
_fn.prototype.a=1;
var v=new _fn();
alert(v.a === 1); /* true */
alert(v.constructor === _fn); /* true */
/* REPLACE PROTOTYPE */
/**
@fn construct HTMLDocumentFragment or HTMLElement from 'html' string in 'doc'
@param html string that contains html
@param doc owner HTMLDocument for result. Optional
@return HTMLDocumentFragment or HTMLElement depend from 'html'
*/
$jb.DOMNode._fromHTML=null;
if("applyElement" in $h)
{