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
xx.yy.zz.ww GET 200 application/javascript 234B 72ms | |
278839520115563000 GET 101 undefined 30B 2.0min | |
278839520115563000 GET 200 text/plain 159B 2.3min | |
278839520115563000 GET 200 text/javascript 166B 20.40s | |
278839520115563000 GET 200 text/javascript 166B 20.06s | |
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 script1 = document.createElement("script"), | |
script2 = document.createElement("script"), | |
script3 = document.createElement("script"), | |
script4 = document.createElement("script") | |
; | |
script1.async = false; | |
script1.src = "../js/mustache-min.js"; | |
script2.async = false; |
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
function foo(done) { | |
setTimeout(done,5000); | |
} | |
function bar(done) { | |
setTimeout(done,1000); | |
} | |
function baz() { | |
alert("all done!"); |
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
function flatten_array(arr) { | |
var i; | |
for (i=0; i<arr.length; ) { | |
if (Object.prototype.toString.call(arr[i]) == "[object Array]") { | |
// prepend `splice()` arguments to `tmp` array, to enable `apply()` call | |
arr.splice.apply(arr,[i,1].concat(arr[i])); | |
continue; | |
} | |
i++; |
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
<script src="LAB.js"></script> | |
<script> | |
// put whatever here, for your page's other scripts that you load with <script> tags. | |
$LAB.script("my_script1.js").script("my_script2.js").wait().script("my_script3.js"); | |
window.fbAsyncInit = function() { | |
FB.init({appId: 'your app id', status: true, cookie: true, | |
xfbml: true}); | |
}; |
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
<!DOCTYPE html> | |
<html> | |
<head>...</head> | |
<body> | |
... | |
<script src="load.js"></script> | |
</body> | |
</html> |
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
sandbox (JSON) { // explicitly list everything to import from the outer scope | |
var foobar = "baz"; // scoped to this sandbox | |
baz = "foobar"; // still scoped to this sandbox, not auto-global. | |
console.log(JSON); // available! | |
console.log(window); // not available because not imported | |
console.log(this); // undefined |
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 $options = $("<option></option>"); | |
$options.add($("<option></option>")); | |
$options.add($("<option></option>")); | |
console.log($options.length); // 1 -- wtf? | |
console.log($options.html()); // <option></option> -- again, wtf? | |
// the documentation for jQuery#add seems to indicate this should work but it doesn't. Any ideas? |
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
/* | |
To see a demo of these in use, check out: http://test.getify.com/test-canvas-clear-alt.html | |
Example uses: | |
*/ | |
clearCircle(context,/*x=*/120,/*y=*/80,/*radius=*/60); | |
clearLineSquared(context,/*x1=*/10,/*y1=*/10,/*x2=*/53,/*y2=*/67,/*thickness=*/5); | |
clearLineRounded(context,/*x1=*/15,/*y1=*/100,/*x2=*/90,/*y2=*/170,/*thickness=*/10); |
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
/** | |
* calculates a set of specificity scores for a CSS selector | |
* based on (but extending) the CSS3 specificity algorithm: | |
* http://reference.sitepoint.com/css/specificity | |
* | |
* @param {string} selector | |
*/ | |
function specificity(selector) { | |
var specificity = [0,0,0,0,0], idx, matches, tmp = 0, | |
selectors = selector.split(/\s*,\s*/) |