I have made a for
loop who call a web worker to highlight code inside code
tag
I have made this loop, this call my worker and do the job.
highlightBase: ->
codes = document.getElementsByClassName('hljs')
if (codes)
for code in codes
HighlightWorker = new Worker('/js/highlight_worker.js')
HighlightWorker.onmessage = (event) ->
code.innerHTML = event.data
HighlightWorker.postMessage(code.textContent)
This is working well but I need to stop this loop until the worker is done.
Is this possible to stop this loop and continue it after or I need to add some timeOut
?