I have made a
codes = document.getElementsByClassName('hljs')
for code in codes
HighlightWorker = new Worker('/js/highlight_worker.js')
HighlightWorker.onmessage = (event) ->
code.innerHTML = event.data
Why do you need to stop the loop? It looks like you are trying to do synchronous tasks, meaning the workers do their job one after the other. But the whole thing about workers is that they are asynchronous...
I guess if you want your code to work synchronously, you need to do something like that:
highlightBase: -> codes = document.getElementsByClassName('hljs') if (codes) for code in codes code.innerHTML = function_that_was_before_made_by_worker()
And that it is...