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)
http://ebok.medialog.no/kompendium/

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
	  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">

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:

page.open(address, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
            phantom.exit();
        } else {
            window.setTimeout(function () {
                page.render(output);
                phantom.exit();
            }, 1000);
        }
    });