Produce & Publish and phantom.js not waiting for for JS to finish

I am using produce and Produce & Publish and Phantomjs to generate PDFs (books)

Unfortunately, there is a lot of JS going on (mathjax), so the PDFs are generated before it is complete.
Resulting in half of the math in the book not being correct.

Any suggestions on what I could try?

In your Phantomjs script, you should not just export the current page directly, you should wait until everything is rendered.
Try to identify a CSS selector to watch that is satisfied only when the rendering is finished.

Not sure why, but a different config of mathjax works:

	<script type="text/javascript" async

For reference:

There is a 'timeout' setting in the script used for phantom.js (rasterize is the default) that seems to fix this.

As mathjax is 'slow', I use:, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
        } else {
            window.setTimeout(function () {
            }, 1000);