Should you use a comma before "while"?
While is a subordinating conjunction, but in some circumstances it can act as an adverb of concession as well. In these circumstances it should have a comma before it.
If you can replace while with as, then it shouldn't have a comma before it. It is just a normal subordinating conjunction.
- The man left the restaurant while it was raining.
If you can replace while with whereas then you should use a comma before it because it is being used as an adverb of concession.
- The man left the restaurant, while his partner stayed.