Using Google PageSpeed Service results in Uncaught ReferenceError: Message is not defined

777 views
Skip to first unread message

Murray

unread,
Jun 27, 2013, 8:47:29 AM6/27/13
to mathja...@googlegroups.com
Hi

I recently implemented PageSpeed Service (which serves content via Google's CDN servers).

PageSpeed has options for optimising HTML (I'm using "Collapse whitespace") and javascript ("combine javascript" and "minify javascript").

Most of my pages came through unscathed (and they certainly load faster).

Two pages that did not fare so well involve the Hub.Queue with the following line:

MathJax.Hub.Queue(function () {Message("*** MathJax is done! ***")});

and the function:

window.Message = function (message) {
***
}

I'm getting "Uncaught ReferenceError: Message is not defined" and MathJax fails to process the page.

I have tried:

(1) Turning on and off all the "optimize HTML" and "optimize javascript" options in PageSpeed - no joy 

(2) Simplifying the definition of window.Message.

Here are the pages without rewriting by Google (they work fine - because I blacklisted them from Google's processes):


And here are the optimized pages that give the error:


I suspect it is a timing issue. I have moved MathJax, jQuery and my own script to different parts of the page, but it doesn't make a difference.

Any suggestions on how to address this would be appreciated.


BTW, PageSpeed Service solved another issue I was about to raise on this forum. Before, it was very common for an Adsense resource to block a MathJax download (or vice-versa), freezing the page for many seconds. But Google seems to do a good job of separating out the two so there is no conflict.

Regards

Murray

Peter Krautzberger

unread,
Jul 1, 2013, 1:47:17 PM7/1/13
to mathja...@googlegroups.com
Hi Murray,

From a quick look, there are a lot of errors in the javascript console so a first step might be to eliminate those (but I admit they happen on both the working and non-working pages and are unrelated to MathJax). 

I'm guessing the page speed service optimizes the order of scripts and their download. That could easily trip up MathJax, especially with the configuration blocks and enhancements in your page.

Sorry for not being more helpful at this point,
Peter.




Murray

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Murray

unread,
Jul 2, 2013, 7:57:29 AM7/2/13
to mathja...@googlegroups.com
Thanks for your reply, Peter.

I suspect I'll just need to re-write some of the code.

You mention "a lot of errors", but of course I would have eliminated any errors before posting here.

The only 2 errors I see on the problem pages (the ones with "_opt" in the file name ) are

(1) "Uncaught ReferenceError: Message is not defined" (this is the error as per the title of this post)

(2) "Error: Permission denied to access property 'toString'" (this is an occasional error caused by badly-written Adsense ads, but this also occurs on the non-optimized pages and doesn't appear to affect anything, certainly not MathJax.)

What other errors are you seeing?

Regards
Murray

Peter Krautzberger

unread,
Jul 2, 2013, 1:42:03 PM7/2/13
to mathja...@googlegroups.com
Hi Murray,

I think a plugin was interfering on my end -- sorry about that!

Peter.

Reply all
Reply to author
Forward
0 new messages