Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Common Error in Production Mode When html is Minified

    Hello everyone, when you set production mode in your Magento 2 and minify the HTML files to speed your website, you often see an error like Parse errorsyntax error, unexpected ‘<‘, expecting end of file”

    or some Fatal error as in the below image –

    Or simply a blank screen.

    The cause of such errors is hidden in the template files. In the following commented code-

    there is no space between the semicolon “;” and the closing tag of php i.e. “?>” which causes the error.

    For the above code, when the HTML file is minified, the closing tag of php is considered as a part of the commented code which is not included in the minified file and throws the error.

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    So, while commenting a php code in a phtml file, make sure that there is a space before the closing tag of php as done in the code below-

    Doing this will avoid the error due to minification of HTML file.

    Hope this will help you.

    For any queries, feel free to comment below.

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again