function takesTime(){
for (var i = 0; i
You can use web workers to achieve your objective, but you'll require a separate js file, and you'll have to add plumbing code to post messages and handle those messages.
node.js doesn't support web workers natively, but an implementation is available at:
https://github.com/cramforce/node-worker/
Otherwise, it's similar to the following code:
var pid = require('child_process').spawn('node', ['childScript.js']) pid.stdout.on('data', function(data) { console.log(data); }); console.log('b');
for (var i = 0; i < some_very_large_number; i++) { // do something synchronous } console.log('a');