I have a fairly large page, liberally sprinkled with MathJax-typeset formulae, and 53 interactive canvas diagrams. In order not to lock everything up, MathJax does its typesetting asynchronously, and for similar purposes I make sure to only actually load canvas diagrams when the user scrolls them into view - this works great, except it makes the page (a primer on Bezier curve maths and implementation) very hard to print: if a user hits print before MathJax is done, the formulae will simply not be there, and even if MathJax finishes, most diagrams won't actually have any content unless the user has scrolled through the entire page. I trickle-load the remaining canvas elements so that every 5 seconds "the next" canvas gets loaded in, but at 53 diagrams this is hardly fast enough to having finished loading if a user wants to print the page right off the bat.
Sadly, this is something that a print.css file can't solve, so I'm trying to find out if there are JavaScript handlers that fire when a user initiates a print command so that I can ensure MathJax is done and all the canvas diagrams get force-loaded before the browser tries to actually print, or print preview, the page.
I found this, http://www.danolsavsky.com/article-intercepting-print-requests-with-javascript.html, which seemed promissing, but doesn't actually seem to do very much in Chrome, Firefox or IE, all of which pop up a print preview before actually printing.
Is there any way to run some JS prior to print (previews)?