Complex JavaScript polyfill and set of methods