Utilities for Javascript plug

Let's name this `utils.py` for consistency with the top-level `utils` module. (I expect this to get absorbed by other modules or divide into more semantically named modules eventually.)