The C Preprocessor in Javascript?

Why on earth...?

β€œ/bin/cpp? Why use that decrepit old thing for Javascript?”, you might ask in a kind of disgusted surprise. β€œIsn't Javascript a modern language with first-class functions, closures, dynamic typing, and so on?” Well, there are still a few things you can't do with Javascript alone:

How do I do it?

In order to sent pre-processed Javascript, your server must pre-process the file before sending it to the client. Most of the advantages of pre-processing are lost if you have to do it manually.

Just configure your web server to pipe Javascript through GNU cpp:

/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C
before minifying and compressing it for transmission.