better way of fixing the SqlAlchemy explain/select issue and ensuring javascript libraries are available to all templates