11

In most (if not all) Magento files, there is commented disclaimers:

/**
* 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 [email protected] so we can send you a copy immediately.
*
*/

There is also code in some themes that are commented out or add comments:

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

or

// Following code does X

I know that php will not execute it, but I'm not sure if by removing all of these unnecessary comments will speed up a website?

0

1 Answer 1

23

In PHP NO, it makes no difference because the PHP code isn't sent out to the browser.

In JavaScript YES, it makes a difference because you want to send less data to the browser. It's recommended to minify your code, this reduces it's size by changing variable names, removing white space, and removing all comments as well. There are many online tools to do this, and it's often available in the IDE.

So, leave your code commented where you work on it, don't remove comments from PHP, and don't minify your JS by hand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.