A call into native code costs more than a call inside it. Cross once with the whole job, not once for every item.
Both halves of main.js add the numbers from 1 to 50,000. The first calls add for each number; the second hands the loop to C++ with one call to sumTo. The work is the same, and the gap between the two timings is the cost of 50,000 crossings.
In a Web Worker each crossing is also a message to another thread, so the gap grows many times over. And native code is not faster by nature: for a small job the crossing can cost more than it saves, so measure, as this sample does.
Try it
Halve and double count, and watch how each timing follows.