Search code examples
pagespeedgoogle-pagespeed

Why does pagespeed module add eval()?


I activated Google PageSpeed module on my site via my cPanel and my site seems to be a lot faster now, but I noticed it adds lots of:

<script>eval(mod_pagespeed_123ABC);</script>
<script>eval(mod_pagespeed_456DEF);</script>

etc..

Does anyone know why they need to be there and if there's a way to remove them?


Solution

  • This is the "Combine JavaScript" (combine_javascript) setting.

    https://developers.google.com/speed/pagespeed/module/filter-js-combine#configuration

    'Combine JavaScript' seeks to reduce the number of HTTP requests made by a browser during page refresh by replacing multiple distinct JavaScript files with a single one.

    This filter employs the Javascript 'eval' expression to evaluate each tag at its proper location in the DOM, but getting the aggregated script content in one HTTP fetch. The effects of this are likely to differ between browsers, and haven't yet been thoroughly measured.