apache / incubator-pagespeed-ngx

Automatic PageSpeed optimization module for Nginx
http://ngxpagespeed.com/
Apache License 2.0
4.37k stars 362 forks source link

\n inside minified javascript #1638

Open blue-eyed-devil opened 5 years ago

blue-eyed-devil commented 5 years ago

i am using latest pagespeed with latest nginx. it was throwing some errors and when i opened minified javascript file I seen that pagespeed added \n for every new line in minified script. here is the sample:

var mod_pagespeed_2SYH0Iu33n = "class UserMediaRecorder {\n constructor(options) {\n this.openbutton = '#openRecordPanel';\n if (typeof options.openbutton !== 'undefined'){\n this.openbutton = options.openbutton;\n }\n this.lengthSeconds = false;\n if (typeof options.limit !== 'undefined'){\n this.lengthSeconds = options.limit;\n }\n this.msecondsLeft;\n this.isPaused = false;\n this.constraints = {audio: true, video: true};\n if (typeof options.constraints !== 'undefined'){\n this.constraints = options.constraints;\n }\n this.containerClass = '';\n if (typeof options.containerClass !== 'undefined'){\n this.containerClass = options.containerClass;\n }\n this.onfileupload = function(blob){console.log(blob);};\n if (typeof options.onfileupload !== 'undefined'){\n this.onfileupload = options.onfileupload;\n }\n\n

jmarantz commented 5 years ago

That does not look like anything I have seen pagespeed do before. Is it possible there is another module loaded into nginx or an upstream origin that is doing some content transformation?

Failing that, can you share the snippet of origin HTML that loads the JavaScript, and also the original js file?

On Thu, Mar 28, 2019, 7:50 AM Igor Mizak notifications@github.com wrote:

i am using latest pagespeed with latest nginx. it was throwing some errors and when i opened minified javascript file I seen that pagespeed added \n for every new line in minified script. here is the sample:

var mod_pagespeed_2SYH0Iu33n = "class UserMediaRecorder {\n constructor(options) {\n this.openbutton = '#openRecordPanel';\n if (typeof options.openbutton !== 'undefined'){\n this.openbutton = options.openbutton;\n }\n this.lengthSeconds = false;\n if (typeof options.limit !== 'undefined'){\n this.lengthSeconds = options.limit;\n }\n this.msecondsLeft;\n this.isPaused = false;\n this.constraints = {audio: true, video: true};\n if (typeof options.constraints !== 'undefined'){\n this.constraints = options.constraints;\n }\n this.containerClass = '';\n if (typeof options.containerClass !== 'undefined'){\n this.containerClass = options.containerClass;\n }\n this.onfileupload = function(blob){console.log(blob);};\n if (typeof options.onfileupload !== 'undefined'){\n this.onfileupload = options.onfileupload;\n }\n\n

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-ngx/issues/1638, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2kPRFnCxW_q7Ck2N3Rnln6kTLNovPPks5vbKyBgaJpZM4cP-B3 .

jmarantz commented 5 years ago

Also please share your config if possible.

On Thu, Mar 28, 2019, 8:54 AM Joshua Marantz jmarantz@google.com wrote:

That does not look like anything I have seen pagespeed do before. Is it possible there is another module loaded into nginx or an upstream origin that is doing some content transformation?

Failing that, can you share the snippet of origin HTML that loads the JavaScript, and also the original js file?

On Thu, Mar 28, 2019, 7:50 AM Igor Mizak notifications@github.com wrote:

i am using latest pagespeed with latest nginx. it was throwing some errors and when i opened minified javascript file I seen that pagespeed added \n for every new line in minified script. here is the sample:

var mod_pagespeed_2SYH0Iu33n = "class UserMediaRecorder {\n constructor(options) {\n this.openbutton = '#openRecordPanel';\n if (typeof options.openbutton !== 'undefined'){\n this.openbutton = options.openbutton;\n }\n this.lengthSeconds = false;\n if (typeof options.limit !== 'undefined'){\n this.lengthSeconds = options.limit;\n }\n this.msecondsLeft;\n this.isPaused = false;\n this.constraints = {audio: true, video: true};\n if (typeof options.constraints !== 'undefined'){\n this.constraints = options.constraints;\n }\n this.containerClass = '';\n if (typeof options.containerClass !== 'undefined'){\n this.containerClass = options.containerClass;\n }\n this.onfileupload = function(blob){console.log(blob);};\n if (typeof options.onfileupload !== 'undefined'){\n this.onfileupload = options.onfileupload;\n }\n\n

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-ngx/issues/1638, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2kPRFnCxW_q7Ck2N3Rnln6kTLNovPPks5vbKyBgaJpZM4cP-B3 .

blue-eyed-devil commented 5 years ago

Here is the config:

pagespeed on; pagespeed EnableCachePurge on; pagespeed FileCachePath /var/cache/pagespeed; pagespeed HonorCsp on; pagespeed LowercaseHtmlNames on; pagespeed XHeaderValue "Powered By ngx_pagespeed"; pagespeed PreserveUrlRelativity on; pagespeed Disallow "/externals/slider-revolution/js/.js"; pagespeed Disallow "https://ajax.googleapis.com/ajax/libs/jquery/*"; pagespeed AvoidRenamingIntrospectiveJavascript off; pagespeed SslCertDirectory /etc/letsencrypt/live/maindomain.com; pagespeed SslCertFile cert.pem; pagespeed MemcachedServers localhost:11211; pagespeed Statistics on; pagespeed StatisticsLogging on; pagespeed LogDir /var/log/pagespeed; pagespeed UsePerVhostStatistics on; pagespeed StatisticsPath /ngx_pagespeed_statistics; pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics; pagespeed MessagesPath /ngx_pagespeed_message; pagespeed ConsolePath /pagespeed_console; pagespeed AdminPath /pagespeed_admin; pagespeed GlobalAdminPath /pagespeed_global_admin; pagespeed MessageBufferSize 100000;

pagespeed EnableFilters responsive_images,resize_images; pagespeed EnableFilters responsive_images_zoom; pagespeed EnableFilters combine_heads; pagespeed EnableFilters outline_css; pagespeed CssOutlineMinBytes 1000; pagespeed EnableFilters outline_javascript; pagespeed JsOutlineMinBytes 1; pagespeed EnableFilters move_css_above_scripts; pagespeed EnableFilters move_css_to_head; pagespeed EnableFilters prioritize_critical_css; pagespeed EnableFilters make_google_analytics_async; pagespeed EnableFilters make_show_ads_async; pagespeed EnableFilters local_storage_cache; pagespeed EnableFilters inline_preview_images; pagespeed EnableFilters resize_mobile_images; pagespeed EnableFilters remove_comments; pagespeed EnableFilters collapse_whitespace; pagespeed EnableFilters elide_attributes; pagespeed EnableFilters trim_urls; pagespeed EnableFilters pedantic; pagespeed EnableFilters remove_quotes; pagespeed EnableFilters convert_meta_tags; pagespeed EnableFilters defer_javascript; pagespeed EnableFilters dedup_inlined_images; pagespeed EnableFilters convert_to_webp_animated; pagespeed EnableFilters lazyload_images; pagespeed LazyloadImagesAfterOnload off; pagespeed EnableFilters insert_dns_prefetch; pagespeed EnableFilters hint_preload_subresources;

pagespeed DisableFilters inline_css; pagespeed DisableFilters inline_javascript;`

blue-eyed-devil commented 5 years ago

and here is the link to joined and minified js file: https://www.testing-site.info/file.js

and link to original file: https://www.testing-site.info/externals/bmd-user-media-recorder/user-media-recorder.js

blue-eyed-devil commented 5 years ago

And here is my NginX build: nginx version: nginx/1.15.8 built with OpenSSL 1.1.1b 26 Feb 2019 TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/opt/rebuildnginx/nginx-1.15.8=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-headers-more-filter --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-auth-pam --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-cache-purge --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-dav-ext --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-ndk --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-echo --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-fancyindex --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/nchan --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-lua --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/rtmp --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-uploadprogress --add-dynamic-module=/opt/push/nginx-push-stream-module --add-dynamic-module=/opt/geoip2/ngx_http_geoip2_module-3.2 --add-module=/opt/pagespeed/incubator-pagespeed-ngx-1.13.35.2-stable --add-module=/opt/httpupload/nginx-upload-module-2.3.0 --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-upstream-fair --add-dynamic-module=/opt/rebuildnginx/nginx-1.15.8/debian/modules/http-subs-filter