- Event delegation included in the core
- JSONP requests
- Defer
This file contains hidden or 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
;(function(window, document){ | |
function getJSONP(url, done){ | |
var callback = "request" + (+new Date()) | |
, script = Element.make("script", { | |
type : "text/javascript", | |
src: url + (!!~url.indexOf("?") ? "&" : "?") + "callback=" + callback | |
}) | |
window[callback] = function(object){ |
This file contains hidden or 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 clickEvent = "createTouch" in document ? "touchend" : "click" | |
// $(myElement).on(clickEvent, ...) | |
// myElement.addEventListener(clickEvent, ...) |
This file contains hidden or 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
function getElementStyle(element, property) { | |
var style = "getComputedStyle" in window ? getComputedStyle(element, null) : element.currentStyle | |
if(!property) return style | |
property = property.replace(/-\D/g, function(a, i){return i !== 0 ? a.charAt(1).toUpperCase() : a.charAt(1)}) | |
return style[property] | |
} |
This file contains hidden or 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
javascript: | |
[].forEach.call( | |
document.querySelectorAll("*") | |
, function(a){ | |
setTimeout(function(){ | |
a.style.border = a.style.border == "" | |
? "" + Math.floor(Math.random()*6) + "px solid " + ["red", "blue", "green", "yellow", "purple"][Math.floor(Math.random()*6)] | |
: "" | |
setTimeout(arguments.callee, 300) | |
}, 300) |
This file contains hidden or 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
function getScripts(string){ | |
var regExp = /<script[^>]*>([\s\S]*?)<\/script>/g | |
, match = string.match(regExp) | |
, i = 0, l, result = [], item | |
if(!match) return function(){} | |
l = match.length | |
for(;i < l; i++) if(item = match[i].replace(regExp, "$1")) result.push(item) | |
if(result) return new Function(result.join(";")) | |
} |
This file contains hidden or 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
function toArray(arrayLike){ | |
var l = arrayLike.length | |
, a = Array(l) | |
for(;l--;) a[l] = arrayLike[l] | |
return a | |
} | |
function getByClass(className, context){ | |
context = context || document | |
if("getElementsByClassName" in context) return toArray(context.getElementsByClassName(className)) |
This file contains hidden or 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
function getCookie(){ | |
var cookie = document.cookie | |
, regExp = /\s*([\w\-]+?)\s*=\s*([^;]*?)\s*(?:;|$)\s*/g | |
, obj = {} | |
cookie.replace(regExp, function(match, name, value){obj[name] = value}) | |
return obj | |
} |
This file contains hidden or 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
;(function(){ | |
function ready(fn){ | |
if (ready.status) window.setTimeout(fn, 0) | |
else ready.stack.push(fn) | |
} | |
function updateStatus(){ | |
var i = 0 | |
if(!/in/.test(document.readyState) && document.body) { |