This is cleaner than having the code in the C and recompile the project for any simple change. There is also added a call to window.webkit.messageHandlers.scheduleIFramesHeightUpdate.postMessage(0); at the end, which caused trouble when being in the C code (there had been issued an "Unsupported return type" error).