Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

combine_javascript with multiple aliased domains causes JS exception #634

Open
GoogleCodeExporter opened this issue Apr 6, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

This is on the latest production version of ModPagespeed.

Oddly when I navigate to www.bimomotor.co.uk, there is a javascript error:

ReferenceError: mod_pagespeed_7QK8uOvs$9 is not defined
[Break On This Error]   

<script>eval(mod_pagespeed_7QK8uOvs$9);</script>

No idea why this happens - as www.bimomotor.com and www.bimomotor.es both work 
(and use exactly the same javascript!).

This only seems to have happened since 1st March.

I have tried clearing the modpagespeed cache completely, but to no effect.

I have had to use
ModPagespeedDisableFilters outline_javascript,rewrite_javascript

The setup in pagespeed.conf causing this issue was:

    # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
    # can set this to "off".
    ModPagespeed on
    ModPagespeedDisallow            */jquery.tinymce.js
    ModPagespeedDisallow            */tiny_mce.js


    # We want VHosts to inherit global configuration.
    # If this is not included, they'll be independent (except for inherently
    # global options), at least for backwards compatibility.
    ModPagespeedInheritVHostConfig on

    # Direct Apache to send all HTML output to the mod_pagespeed
    # output handler.
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html


    # Override the mod_pagespeed 'rewrite level'. The default level
    # "CoreFilters" uses a set of rewrite filters that are generally
    # safe for most web pages. Most sites should not need to change
    # this value and can instead fine-tune the configuration using the
    # ModPagespeedDisableFilters and ModPagespeedEnableFilters
    # directives, below. Valid values for ModPagespeedRewriteLevel are
    # PassThrough, CoreFilters and TestingCoreFilters.
    #
    ModPagespeedRewriteLevel CoreFilters


    ModPagespeedEnableFilters collapse_whitespace,outline_css,outline_javascript,rewrite_javascript
    ModPagespeedEnableFilters combine_css,rewrite_css,elide_attributes,rewrite_style_attributes
    ModPagespeedEnableFilters make_google_analytics_async,combine_javascript
    ModPagespeedEnableFilters move_css_above_scripts,remove_comments,sprite_images
    ModPagespeedEnableFilters inline_images,convert_jpeg_to_webp,resize_mobile_images
    ModPagespeedEnableFilters convert_jpeg_to_progressive,fallback_rewrite_css_urls
    ModPagespeedEnableFilters move_css_above_scripts,trim_urls
    ModPagespeedEnableFilters extend_cache
    # ModPagespeedEnableFilters insert_image_dimensions,inline_preview_images,defer_javascript

    ModPagespeedDomain www.bimomotor.*
    ModPagespeedDomain bimomotor.*

    ModPagespeedMapOriginDomain localhost *.bimomotor.*
    ModPagespeedMapOriginDomain localhost bimomotor.*
    ModPagespeedMapOriginDomain http://localhost https://www.bimomotor.*

    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/themes/mails/" "/var/www/html/themes/mails/"
    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/uploaded/img/" "/var/www/html/uploaded/img/"
    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/themes/enuukGrey/css/" "/var/www/html/themes/enuukGrey/css/"
    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/themes/enuukGrey/img/" "/var/www/html/themes/enuukGrey/img/"
    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/themes/enuukGrey/js/" "/var/www/html/themes/default/js/"
    ModPagespeedLoadFromFileMatch "^https?://(?:www.)?bimomotor.*/themes/default/js/" "/var/www/html/themes/default/js/"

    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*themes/mails/" "/var/www/html/themes/mails/"
    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*uploaded/img/" "/var/www/html/uploaded/img/"
    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*themes/enuukGrey/css/" "/var/www/html/themes/enuukGrey/css/"
    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*themes/enuukGrey/img/" "/var/www/html/themes/enuukGrey/img/"
    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*themes/enuukGrey/js/" "/var/www/html/themes/default/js/"
    ModPagespeedLoadFromFileMatch "^https?://127.0.0.1/.*themes/default/js/" "/var/www/html/themes/default/js/"

    ModPagespeedLoadFromFileMatch "^http://(?:www.)?bimomotor.*/phpbb/styles/" "/var/www/html/phpbb/styles"
    ModPagespeedLoadFromFile "http://127.0.0.1/phpbb/styles/" "/var/www/html/phpbb/styles"

    ModPagespeedFetchWithGzip on
    SetOutputFilter DEFLATE    

Original issue reported on code.google.com by rwap.services on 4 Mar 2013 at 11:12

@GoogleCodeExporter
Copy link
Author

Original comment by jmara...@google.com on 4 Mar 2013 at 12:49

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Summary was: Inline JS file not found !!

Original comment by jmara...@google.com on 4 Mar 2013 at 7:49

  • Changed title: combine_javascript with multiple aliased domains causes JS exception

@pySilver
Copy link

I'm facing the same issue. It's been 3 and I assume it's not fixed, right?

My setup is the following A.com/b [dir /b proxy_pass to] -> B.com/ [this is where pagespeed is installed]

B.com authorizes both domains via pagespeed Domain directive. And here the result:

URL: https://a.com/b/somepage/

<script src="https://a.com/b/somefiles.min.js,qver==1.1.13+readmore.min.js,qver==1.1.13.pagespeed.jc.XQoUShKijI.js"></script>
<script>eval(mod_pagespeed_B4Q2861Jx2);</script> <-- this id are not mentioned in above script
<script>eval(mod_pagespeed_GbZ0EMVee5);</script> <-- this id are not mentioned in above script

Same URL at second domain: https://b.com/somepage/

<script src="https://b.com/somefiles.min.js,qver==1.1.13+readmore.min.js,qver==1.1.13.pagespeed.jc.Rxyn2edOtN.js"></script>
<script>eval(mod_pagespeed_01_huc9P8R);</script> <-- this id IS mentioned in above script
<script>eval(mod_pagespeed_BuMGtAp1Fq);</script> <-- this id IS mentioned in above script

What is funny here:

  • 2 generated scripts have different names (...XQoUShKijI.js, ...Rxyn2edOtN.js) but they are identical
  • so, js placed at A.com has IDs from B.com

@pySilver
Copy link

its worth to mention that sub_filter is running when A.com alias is used. Sub_filter modifies links b.com -> a.com/b

@pySilver
Copy link

I can say for sure that the nginx sub_filter is the cause (not guilty though). Once disabled all ids of combine filter works as expected.

@oschaaf
Copy link
Member

oschaaf commented Sep 13, 2018

Maybe it’s a filter ordering issue. Which one runs last, the sub filter or the pagespeed filter? Tweaking the optimized output may break stuff

@pySilver
Copy link

@oschaaf afaik there is no way to influence the order of output filters in nginx however I'm sure that sub_filter runs before pagespeed. What sub_filter does is simply changes href links from <a href="https://original.com/path/to/page">clk</a> to a <a href="https://alias.com/x/path/to/page">clk</a>

Is there any hashing of html source involved in pagespeed? Or does it query for html page in background as it does for static resources?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants