Pearl Theme - Speed Optimization Extension - Javascript Error
Hi,
we have the Magento 2.3.4 CE, Pearl Theme 1.10 and Algolia Extension.
I mention here the Algolia extension because it inserts Javascript into the pages and this Javascript is broken after the 'minify' by jsShrink.
The script blocks are of type '<script type="text/template">'. They often contain more html code than javascript, so jsShrink probably doesn't work well here.
The error happens in the class 'app/code/WorldPixel/SpeedOptimization/Observer/BlockAfterToHtml.php' in line 95.
jsShrink makes the following lines...
<script type="text/template" id="autocomplete_categories_template">
<a class="algoliasearch-autocomplete-hit" href="{{url}}">
{{#image_url}}
<div class="thumb">
<img src="{{{image_url}}}" alt="{{{name}}}" /></div>
{{/image_url}}
{{#image_url}}
<div class="info">
{{/image_url}}
{{^image_url}}
<div class="info-without-thumb">
{{#_highlightResult.path}}
{{{_highlightResult.path.value}}}
{{/_highlightResult.path}}
{{^_highlightResult.path}}
{{{path}}}
{{/_highlightResult.path}}
{{#product_count}}
<small>({{product_count}})</small>
{{/product_count}}</div>
<div class="algolia-clearfix"></div>
{{/image_url}}</div></a></script>
... this code.
<!-- Category hit template --><script type="text/template"id="autocomplete_categories_template"><a class="algoliasearch-autocomplete-hit"href="{{url}}">{{#image_url}}<div class="thumb"><img src="{{{image_url}}}"alt="{{{name}}}"/></div>{{/image_url}}{{#image_url}}<div class="info">{{/image_url}}{{^image_url}}<div class="info-without-thumb">{{#_highlightResult.path}}{{{_highlightResult.path.value}}}{{/_highlightResult.path}}{{^_highlightResult.path}}{{{path}}}{{/_highlightResult.path}}{{#product_count}}<small>({{product_count}})</small>{{/product_count}}</div><div class="algolia-clearfix"></div>{{/image_url}}</div></a></script>
It removes whitespace, so the code is no longer valid html and the javascript Template Engine has problems parsing it.
As a temporary solution we have now excluded Javascript of type 'text/template' from being minified.
It would be useful to find a better solution for the future.
Greetings from Hannover/Germany
Lutz
Please sign in to leave a comment.
Comments
0 comments