This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
// ----------------------------------------------------------------------------- | |
/* Shame CSS */ | |
// This is not a dumping ground. It is a staging area for hacks that are | |
// intended to be fixed and resolved so as not to sully our | |
// production-ready codebase. Hacks are necessary, but they are not | |
// permanent, nor are they acceptable long-term. You are not done when | |
// you've moved your selector and rules here. | |
// This is not intended to be an easy fix, or a simple way out. You will | |
// spend time writing out your shame, and you will make it known that |
Function.prototype.runOnBackgroundThread = function (aCallback) { | |
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"}); | |
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob)); | |
_worker.onmessage = aCallback; | |
_worker.postMessage(); | |
} | |
var _test = function () { | |
postMessage((1+1).toString()); | |
} |