In modern browsers, you can use a webworker. – Kevin B
I used webworker to fix this problem, so the heavy parsing is in the background and doesn't freeze the browser as well.
Though it doesn't work in IE9 and other browsers mentioned here, I just made a work around:
if (window['Worker']) { ... }
which means if it supports the webworker. Those that don't support the webworker hangs (still using my old code), but the browser versions which does work perfectly.