I want to share a pretty cool pattern for collaborating on JavaScript files.
A little background
In the application I am working on, we have a need to keep all of our JS in one file that is committed to subversion and included in the application. This one file is updated multiple times by members of our team and as a result needs to be frequently merged. Sure we could use includes of some sort to simplify this process but that has overhead of it's own. I am sure that a lot of teams have more then one hand in the Java Script cookie jar at a time.
The pattern
<script>
//Promoted Code
(function(){
//Stuff
}())
//John's Code
(function(){
//Stuff
}())
//Paul's Code
(function(){
//Stuff
}())
</script>
What does this format offer?
This pattern may seem simple but those are sometimes the best kind. I have noticed a dramatic improvement in my ability to work on these files in collaboration with other developers. garbage collection
See more posts from Eric Gelinas on blog.standardpixel.com