a-r-m-i-n / min

TYPO3 CMS extension "min" - Compressed CSS, JS and HTML output for TYPO3
7 stars 8 forks source link

Loading error by using email mailto #22

Closed ProWebs closed 1 month ago

ProWebs commented 10 months ago

All sites with a "mailto" can't load any more after activating the plugin. They are loading endless with a white site. No error will be generated in logs.

This same happens if a form is used on a site.

We have t3 v11.5.32 running with php 8.0 and min v. 2.1.3

ProWebs commented 10 months ago

With this configuration i can solve me problem, but this not the final solution.

plugin.tx_min.assetCollector { compressCss = 1 compressInlineCss = 1 compressJs = 0 compressInlineJs = 1 }

a-r-m-i-n commented 10 months ago

Thanks for reporting. Need to investigate this further. Minifying the JS which provides the mailto functionality shouldn't break.

ProWebs commented 9 months ago

So you could reproduce it :)

Shotte commented 8 months ago

I have similar situation using t3sbootstrap extension. Only after using your workaround "compressJs = 0" for assetCollector helps. Otherwise Firefox identifies a decode error due to a copressed file but not appending the file extension ".gzip" (using Typo3 11.5).

a-r-m-i-n commented 8 months ago

Sounds like the issue #21 which is fixed in v3 of EXT:min.

Could you try to patch the extension, like I did for v3 and check if it works for you?

I did not plan to fix release v2 anymore and I'm pretty busy right now. That would help a lot. I'm going to add a new 2.x branch which allows you, to provide a merge request for this.

a-r-m-i-n commented 8 months ago

Oh. There is already a 2.x branch existing 😁

Shotte commented 8 months ago

Hi @a-r-m-i-n, thank you for your quick response. Meanwhile I tried two things:

1) installing 2.x branch: typo3 v11.5.33 announced error due to a missing file(s): .../ext/min/Resources/Private/PHP/vendor/autoload.php It seems that the whole folder "vendor" is missing

2) I figured out your patch: in Classes/Minifier.php you added some codelines (see below). I patched it in my original file from TER installation (version 2.1.3) but it had no effect. The file extension ".gzip" is still missing even though it is already a compressed file. if (!file_exists($sourceFilePath)) { // Do not proceed, if file is missing $filesAfterCompression[$key] = $config; continue; } // Check for gzipped assets $file = fopen($sourceFilePath, 'rb'); $firstBytes = fread($file, 2); fclose($file); if ($firstBytes === "\x1F\x8B") { // Do not proceed, if given asset is gzipped $filesAfterCompression[$key] = $config; continue; }

Any more suggestions?

a-r-m-i-n commented 8 months ago

@Shotte To 1: For TER release you need to perform a composer install in the Private/PHP folder manually. I always do this, before uploading a new release to TER.

To 2: Too bad. I thought this could help.

But what this code fixes, is to minify already gzipped code. Your issue sounds different. You include gzipped code, but the browser doesn't expect gzip here.

Could you provide how you've configured/included the JS file and show me, how the file is included in HTML output of TYPO3 (full path to the compressed file would help)? Thanks.

a-r-m-i-n commented 8 months ago

Hm. I'm wondering that your code is gzipped, but the file extension is missing. Are the source files you are including already gzipped? @Shotte

Shotte commented 8 months ago

@a-r-m-i-n I will try to satify your requests:

I added two screenshots from the typo3 generated html code. One with the problematic t3sbootstrap.js file after setting the parameter "compressJs = 0" (filename: min-no-asset-js.jpg, first picture) and one with "compressJs = 1" (filename min-with-asset-js.jpg, second picture) min-no-asset-js min-with-asset-js

As you can see, both situations lead to filenames without ".gzip" as file ending.

Your extension is included in the template the way you suggested it: min-template-setup

The JS-file is automatically included by the t3sbootstrap extension, which provides me fully already prepared templates. Thus I don't need to setup it by my own (helpful, because I'm not deeply familiar with typo3 templates). The JS-file itself is automatically generated by the extension depending on the in the BE activated components.

Is this information sufficient to you?

a-r-m-i-n commented 8 months ago

Hm. What is weird this js file also does not contain the ".min" suffix and is not located in compressed sub-directory. It seems that this JS file is not being processed by the min extension at all.

Could you disable/uninstall the min extension and check if this generated JS file works?

If not, I guess that this is an issue in t3sbootstrap extension with gzip enabled.

a-r-m-i-n commented 8 months ago

With this configuration i can solve me problem, but this not the final solution.

plugin.tx_min.assetCollector { compressCss = 1 compressInlineCss = 1 compressJs = 0 compressInlineJs = 1 }

@ProWebs I think the issue you have is not the same Shotte has. To reproduce your issue, I need more information. Does the JS error console in your browser has any entries? You say the disabling compressJs for asset collector works, but TYPO3's mail encryption script is not injected via asset collector, by default.

Could you also identify which JS file causes the issues when being compressed, and attach this file to the issue? Thanks.

Shotte commented 8 months ago

@a-r-m-i-n the compressed files are generated (see screenshot below) but only the related css file in the header has the correct link to the compressed folder. Might this be a problem with files in the footer section? Or you are right that there are incompatibilities with the t3sbootstrap extension.

min-with-asse-headert-js

generated files: min-with-asset-generated-js

a-r-m-i-n commented 8 months ago

@Shotte ? Also some of the JS files got compressed, by min extension. As I mentioned before: Please disable/uninstall min and check if the generated and gzipped JS file, still makes issues in your Firefox browser. If yes, this definitely not a min issue.

Shotte commented 8 months ago

@a-r-m-i-n I can give it a try, but I don't understand why typo3 shall gzip the JS file when min is deactivated? Or do you mean that I should keep typo3 builtin compress settings I have currently commented out in the template? Sorry for my naive questions but I'm still not highly familiar with typo3...

a-r-m-i-n commented 8 months ago

TYPO3 has an own compressor which concatenates and gzippes css and js files. What it is not doing is minifying it.

Min additionally minifies the assets and only gzippes them, when the system setting is enabled.

So, your gzip issue is probably not caused by min. Please check it.