[resolved] 3.5 RC3 New media uploader doesn't work with Google mod_pagespeed (27 posts)

  1. I enable Google mod_pagespped (https://developers.google.com/speed/pagespeed/mod) stable version on my server with default configuration. but the new media uploader doesn't work with it. The following error showing up in Console:

    Uncaught SyntaxError: Unexpected token ILLEGAL load-scripts.php,qc=0,aload,5B,5D=admin-bar,,hoverIntent,,common,,jquery-ui-widget,,jquery-ui-position,,wp-pointer,,wp-ajax-response,,jquery-color,,wp-lists,,quicktags,,jqu,aload,5B,5D=ery-query,,admin-comments,,jquery-ui-core,,jquery-ui-mouse,,jquery-ui-sortable,,postbox,,dashboard,,customize-base,,customize-loader,,thi,aload,5B,5D=ckbox,,plugin-install,,underscore,,shortcode,,media-upload,,backbone,,media-models,,plupload,,plupload-html5,,plupload-flash,,plupload-sil,aload,5B,5D=verlight,,plupload-html4,,wp-plupload,,media-views,,media-editor,,word-count,,jquery-ui-resizable,,jquery-ui-draggable,,jquery-ui-button,aload,5B,5D=,,jquery-ui-dialog,,wpdialogs,,wplink,,wpdialogs-popup,aver=3.5-RC4-23115.pagespeed.jm.cCB9FUYs4G.js:32
  2. George Stephanis
    Code Monkey
    Posted 2 years ago #

    Please add

    define('SCRIPT_DEBUG', true);

    to your wp-config.php file and try again. That should help in tracking down which of the combined scripts is causing the issue.

  3. Drew Jaynes
    Docs Czar
    Posted 2 years ago #

    Hi Tunghsiao,

    Are you still having issues with mod_pagespeed on a fresh copy of 3.5?

  4. Hi Drew,

    Sorry for my late reply. I upgraded to 3.5 release and added define('SCRIPT_DEBUG', true); to my wp-config.php, the media uploader works as expected. But when I commented out the debug code. I got the same error again.

  5. Jacob Allred
    Posted 2 years ago #

    Same here. I am using mod_pagespeed and WordPress 3.5, but can't use the media uploader without define('SCRIPT_DEBUG', true); in my wp-config.php.

  6. What host are you guys on, and did you install Google Pagespeed on your own, or did they do it?

  7. Jacob Allred
    Posted 2 years ago #

    @Ipstenu, this looks like a known issue that you are aware of.

    I'm on a dedicated server running CentOS 6.3 64-bit. I installed mod_pagespeed using the yum package manager, following the instructions provided by Google, with a largely unchanged configuration file.

    I was able to modify my configuration to exclude anything with wp-admin in it, and this fixed the problem without having to modify each of my blog's wp-config.php files. I just had to add this line to my pagespeed.conf, then restart Apache: ModPagespeedDisallow */wp-admin/*

    It'd be great if this configuration change wasn't necessary. Please let me know if there is anything I can do to help test/troubleshoot this issue.

  8. Well you sure made one of my coworkers feel a lot less crazy :) (That list is actually curated by all the forum mods, I just posted it, so I didn't know we added that. I wasn't 100% sure this wasn't just the company I work for having a problem!)

  9. j_marantz
    Posted 2 years ago #

    Hello from the mod_pagespeed team.

    The workaround of 'disallow */wp-admin/*' is a fine one. We've seen this before. We'd love to understand better what the problem is with mod_pagespeed's optimizations in the /wp-admin/ page and figure out how to resolve them.

    Would it be possible to tell us the full URL from the original comment? The one that begins with "load-scripts.php,qc=0,alo" and ends with "5-RC4-23115.pagespeed.jm.cCB9FUYs4G.js"?

    Hopefully this is something we can resolve in mod_pagespeed itself.


  10. Thanks for all your replies.

    @j_marantz Yes, here's the full URL in console:


    And I also got a workaround solution by disable rewrite_javascript in pagespeed.conf:

    ModPagespeedDisableFilters rewrite_javascript

    I know it's one of the core functions but this works for me.

  11. j_marantz
    Posted 2 years ago #

    Thanks Tunghsaio.

    Can you provide the entire URL including the domain and path?

    I did not think we had a bug in our JS minifier but it seems likely, based on your experience, that we do. With a testcase of JS text we can find it & fix it.


  12. @j_marantz

    Here it is:

  13. j_marantz
    Posted 2 years ago #

    Thanks again! Sorry to bother you. I probably need the HTML file that loads that script.

    That script by itself (I hand-decoded the .pagespeed. url) without mod_pagespeed gets an undefined reference (Uncaught ReferenceError: jQuery is not defined load-scripts.php:2). I reproduced using this HTML:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <script src="http://postholic.com/wp-admin/load-scripts.php?c=1&load[]=admin-bar,hoverIntent,common,wp-ajax-response,jquery-color,wp-lists,quicktags,jquery-query,admin-comments,jquery-ui-core,jquery-&load[]=ui-widget,jquery-ui-mouse,jquery-ui-sortable,postbox,dashboard,customize-base,customize-loader,thickbox,plugin-install,underscor&load[]=e,shortcode,media-upload,backbone,media-models,plupload,plupload-html5,plupload-flash,plupload-silverlight,plupload-html4,wp-plu&load[]=pload,media-views,media-editor,word-count,jquery-ui-resizable,jquery-ui-draggable,jquery-ui-button,jquery-ui-position,jquery-ui-&load[]=dialog,wpdialogs,wplink,wpdialogs-popup&ver=3.5"></script>

    Probably that's a red herring and you have that jQuery defined by some earlier scripts (I can guess which one, I know). But I want to make sure I reproduce your testcase.

  14. @j_marantz

    HTML output (will expire in 24 hrs):


    mod_pagespeed enabled with default settings. WP_DEBUG is off.

    If it's necessary to login to the backend Dashboard, I can create a temporary account for you :)

  15. j_marantz
    Posted 2 years ago #

    I had two problems writing the HTML from your pastebin into a file and loading that into Chrome. They were related to CSS & JS from 'akismet'. Those resources were returning 403 (not authorized). This was showing up in Firebug for me. I am wondering if this is related to mod_pagespeed issue 582.

    Are you running Apache as a reverse proxy?

    I resolved those issues by editing those two 'akismet' URLs to strip out the .pagespeed. syntax and fetch instead the origin resources. Then the HTML loads with errors in Chrome.

  16. @j_marantz: I think this issue is not related with the media manager. After commenting out Akismet css and js files. I still got the same error when I click "Add media" button, In my case, this button: https://files.sparanoid.com/image-ZfGbf4UzOp.png

    However, yes, the problem you described is another one, I'm running Apache as a backend and I put nginx as a reserve proxy in front of it. Thanks for the hint.

  17. CrowderSoup
    Posted 2 years ago #

    The work-around "ModPagespeedDisallow */wp-admin/*" worked for me.

  18. FWIW, it's Google at fault here, and not WP :/ They're compressing compressed files.


  19. j_marantz
    Posted 2 years ago #

    @Mika - This may be a mod_pagespeed issue but it is strange that it only happens on /wp-admin. In any case we would love to get to the bottom of this.

    When you say "compressed" you are talking about minifying JavaScript, is that right? It should not be a functional problem if that occurs twice. The second time might not do much shrinking, but it shouldn't break anything.

    Or are you really talking about gzip compression. In that case, mod_pagespeed isn't doing anything at all, except for enabling mod_deflate.

    BTW we have a fix for Issue 582 described above in trunk (not in a binary release yet). That is related to a 403 problem.

    Another possibility is that there is some JavaScript in WordPress /wp-admin/ stack that is scanning URLs in the DOM looking for certain patterns. mod_pagespeed changes URLs, and that can break JavaScript that is looking for specific URLs.

  20. Paul Schreiber
    Posted 2 years ago #

    The work-around "ModPagespeedDisallow */wp-admin/*" worked for me, too.

  21. j_marantz
    Posted 2 years ago #

    Hi, I'm here with an update from the mod_pagespeed perspective.

    1. In mod_pagespeed 1.4 (beta) we put "disallow */wp-admin/*" in our
    base configuration so no one should see this anymore or have to do
    it in their own configs. Note this has not made the mod_pagespeed
    stable channel yet.

    2. We launched a deeper investigation about the incompatibility here:
    https://code.google.com/p/modpagespeed/issues/detail?id=675 and will
    be fixing the root problem. It appears that there are two issues:
    a) UTF-8 BOM in jquery.query.js http://core.trac.wordpress.org/ticket/23315 which some wordpress plugin
    will concatenate and leave in the middle of the file
    b) The way mod_pagespeed minifies that file doesn't handle the embedded
    UTF-8 BOM. We should be able to make mod_pagespeed resilient to this.

    Stay tuned.

  22. j_karlin
    Posted 2 years ago #

    @Tunghsiao Liu: The problem may be fixed in the latest beta of mod_pagespeed, which your site appears to be running already. Can you try adding:

    ModPagespeed on
    ModPagespeedAllow */wp-admin/*

    to either your pagespeed.conf or .htaccess in your wordpress root directory and see if the wp-admin pages:
    1) do have pagespeed applied to them (look for .pagespeed. resources in the source)
    2) work correctly?



  23. Hi @j_marantz and @j_karlin:

    Thanks for your effort but unfortunately it still doen't work for me :(

    1) .pagespeed. seems applied to scripts correctly.
    2) I doesn't work: I still got this error: Uncaught SyntaxError: Unexpected token ILLEGAL,
    3) I got another error in console: GET http://postholic.com/wp-content/plugins/akismet/akismet.js,qver= 403 (Forbidden), but after some page refreshes, this error is gone.

    The version of mod_pagespeed installed on my server is beta.

    Here's a dumped script and Console screenshot, I hope they may help.


  24. j_marantz
    Posted 2 years ago #

    Thanks for trying it out, Tunghsiao.

    Unfortunately we weren't clear: the bug has been fixed in our trunk code, but has not been released in binary form yet. We'll update this thread again.

    Sorry about the confusion.

  25. @j_marantz: Cool, can't wait to try it out!

  26. j_marantz
    Posted 2 years ago #

    The fix for rewrite_javascript was released with mod_pagespeed 1.5.


    Although we somehow omitted this bug-fix from the release notes, it is indeed fixed for that release: https://code.google.com/p/modpagespeed/issues/detail?id=675

    As posted earlier, you'll have to add:
    ModPagespeedAllow */wp-admin/*

    to see this bug-fix in action, as we left the by-default blacklist of wp-admin compiled into the code. We'd love to see if this gets past the problem for you and then we can remove the default blacklist.

  27. @j_marantz great, it works!

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Tunghsiao Liu (a.k.a. Sparanoid)
  • Latest reply from Tunghsiao Liu (a.k.a. Sparanoid)
  • This topic is resolved
  • WordPress version: 3.53