删除注释代码是否可以加速Magento网站?


11

在大多数(如果不是全部)Magento文件中,有注释的免责声明:

/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
*/

在某些主题中也有被注释掉或添加注释的代码:

 // echo "PickupAtStore.days=[" . implode(',', $data) . "]\r\n</script>";

要么

// Following code does X

我知道php不会执行它,但是我不确定通过删除所有这些不必要的注释是否可以加快网站速度?

Answers:


23

PHP NO中,这没有什么区别,因为PHP代码不会发送到浏览器。

JavaScript YES中,它有所不同,因为您希望向浏览器发送更少的数据。建议最小化代码,这可以通过更改变量名称,删除空格以及删除所有注释来减小代码的大小。有许多在线工具可以执行此操作,并且通常可以在IDE中使用。

因此,请在使用代码的地方添加注释,不要从PHP中删除注释,也不要手工缩小JS。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.