script as function; replacing should with assert; trim() polyfill