PDA

View Full Version : Does white space hurt


K4GAP
10-22-2013, 04:52 PM
I've noticed in the code (any vb code) there are sometimes spaces between lines of code. Does that have any adverse effect on load time?

Is there a reason for what I call white space?

Would it hurt anything if I closed up all the code so there was no "white space"?

squidsk
10-22-2013, 07:40 PM
I've noticed in the code (any vb code) there are sometimes spaces between lines of code. Does that have any adverse effect on load time?

Is there a reason for what I call white space?

Would it hurt anything if I closed up all the code so there was no "white space"?
White space in php has no bearing on load time, due to the fact that the php is run server side and ignores whitespace. Long story short there's no benefit to removing whitespace from php but there is a downside, which is that if you ever need to find something in the code it becomes significantly more difficult to do so since it is no longer readable.

As an aside, javascript and css there's a benefit to having minimal whitespace, which is why vbulletin css (and js I believe) by default comes minified because it saves you bandwidth to send a file with minimal size.

K4GAP
10-30-2013, 03:50 AM
White space in php has no bearing on load time, due to the fact that the php is run server side and ignores whitespace. Long story short there's no benefit to removing whitespace from php but there is a downside, which is that if you ever need to find something in the code it becomes significantly more difficult to do so since it is no longer readable.

As an aside, javascript and css there's a benefit to having minimal whitespace, which is why vbulletin css (and js I believe) by default comes minified because it saves you bandwidth to send a file with minimal size.

Thanks for the explanation.

Digital Jedi
10-30-2013, 06:16 AM
Just to clarify further, in code white space is not the line breaks, which is what I think you were referring to specifically. White space is anywhere the space bar was pressed. So minified CSS and JavaScript remove white space, new lines and tabs from the code and compresses it down to practically unreadable code (http://www.vbulletin.com/forum/core/clientscript/vbulletin_css/style00055l/1382047753-main-cssnormalization.css). But it does save some resources. However, if you were thinking of just removing space and lines inside templates, then the effect on page load would be negligible and make it harder to read (and upgrade).