javascript - Spaces in equal signs -


i'm wondering there difference in performance using removing spaces before , after equal signs. 2 code snippets.

first

int = 0; 

second

int i=0; 

i'm using first one, friend learning html/javascript told me coding inefficient. true in html/javascript? , huge bump in performance? same in c++/c# , other programming languages? , indent, said 3 spaces better tab. used code this. want know if correct.

your friend bit misguided.

the spaces in code make small difference in size of js file make small difference in download speed, though i'd surprised if noticeable or meaningful.

the spaces unlikely make meaningful difference in time parse file.

once file parsed, spaces not make difference in execution speed since not part of parsed code.


if want optimize download or parse speed, way write code in readable fashion possible best maintainability , use minimizer deployed code , standard practice many web sites. give best of both worlds - maintainable, readable code , minimum deployed size.

a minimizer remove unnecessary spacing, shorten names of variables, remove comments, collapse lines, etc... designed make deployed code small possible without changing run-time meaning of code @ all.


c++ compiled language. such, compiler developer uses sees spaces (same comments). spaces gone once code has been compiled native code end-user gets , runs. so, issues spaces between elements in line not applicable @ c++.

javascript interpreted language. means source code downloaded browser , browser parses code @ runtime opcode form interpreter can run. spaces in javascript part of downloaded code (if don't use minimizer remove them), once code parsed, spaces not part of run-time performance of code. thus, spaces have small influence on download time , perhaps smaller influence on parse time (though i'm guessing unlikely measurable or meaningful). said above, way optimize javascript use spaces enhance readability in source code , run minimizer on code generate deployed version of code minimize deployed size of file. preserves maximum readability , minimizes download size.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -