sourcegraph / appdash

Application tracing system for Go, based on Google's Dapper.
https://sourcegraph.com
Other
1.72k stars 137 forks source link

Clean global js namespace #50

Closed slimsag closed 9 years ago

slimsag commented 9 years ago

Variables declared in JS through a simple:

var x = 0;

Are said to live in the global namespace. They can conflict with one another at any point. We use a few separate <script> tags for documentation and code separation purposes -- so it's hard to ensure that they do not declare conflicting variables and interfere with one another.

Instead, we now use an anonymous closure whose variables etc are local to that function's scope. For example:

(function() {
  var x = 0;
})();

The diff is probably not very readable due to the old code being out-dented by two additional spaces now. But the above should make the intent of this change clear.

Can be merged after Travis is done checking #49 (or I'll re-base and send again if further changes are needed).