crowell / modpagespeed_tmp

Automatically exported from code.google.com/p/modpagespeed
Apache License 2.0
0 stars 0 forks source link

Insert "js_defer" script URL with absolute path #741

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I recently updated to mod_pagespeed version 1.4.26.3 and I noticed that when 
"defer_javascript" is enabled the following script is inserted at the end of 
the document :
<script type="text/javascript" src="/mod_pagespeed_static/js_defer.js"></script>

In the previous version of "mod_pagespeed", the necessary js code was inlined 
in the head of the document and it worked great !

Here is the problem : on the pages where I want javascript defer enabled, I 
have a "base" tag pointing to a different domain, therefore the link to 
"js_defer" is broken :(

Take a look at the following example :
A page is hosted on http://www.my-site.com, which has mod_pagespeed installed

The code on the page :
<html>
    <head>
        <base href="http://www.another-site.com">
        .............................................................. 
    </head>
    <body>
        ..............................................................
        <script type="text/javascript" src="/mod_pagespeed_static/js_defer.js"></script>
    </body>
</html>

The "js_defer.js" is not found on http://www.another-site.com (obviously)

My question : is it possible to tell defer javascript to insert the script with 
a full path URL (http://www.my-site.com/mod_pagespeed_static/js_defer.js) ?

Thanks in advance for your help !

P.S. : I have the same problem whit the filter "lazyload_images" because the 
empty image replacement file is served from "/mod_pagespeed_static" folder also.

Original issue reported on code.google.com by cosmin.m...@gmail.com on 10 Jul 2013 at 9:21

GoogleCodeExporter commented 9 years ago
Good catch, we should indeed be inserting absolute urls for these scripts 
rather than relative ones for exactly this scenario.  I'll take a look at this.

Original comment by jmaes...@google.com on 11 Jul 2013 at 6:26

GoogleCodeExporter commented 9 years ago
Thank you, I'm looking forward to this fix. I actually disabled for now the 
filters "defer javascript" and "lazyload images" on my site, www.hinto.co, in 
order to work correctly.

Original comment by cosmin.m...@gmail.com on 11 Jul 2013 at 6:51