All SDL2 code examples from http://lazyfoo.net/tutorials/SDL/ with Makefile and compatible with emscripten (http://kripken.github.io/emscripten-site/)
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
sudo apt-get install libglu1-mesa-dev libglew-dev
Run:
make
Install and configure emscripten, and run:
make js