DEV: removes jquery usage from highlight-syntax (PR #10564)

Note that this commit also moves loadScript out of the loop so we only call it once. AFAICT, I see no reason to call it on each loop.

GitHub

I think this call can also be moved out of the loop?

I don’t know how it affects the performance, but before the change it was running all highlightBlock concurrently (essentially forEach(a => new Promise(() => highlightBlock(a)))) and now it runs them synchronously though still within a promise (i.e. new Promise(() => forEach(a => highlightBlock(a))))

Hmmm yes indeed, at best it was an unknown desirable side-effect I would say. I doubt anyone would use the promise created by loadScript to make this more performant on purpose.

this is on each selected node of the loop not on the top node no?

I meant customHighlightJSLanguages - I don’t think the list of languages will change between iterations of the loop. :wink:

Yes I think this is probably something we can pull out of the loop