This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*\[/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* tnx @kangax for idea */ | |
var i, n = 400000, | |
_fn = function(){}, that = {}, args = []; | |
console.time("call"); | |
i = n; while(i--) | |
{ | |
_fn.call(that); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@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) | |
{ |