SpicyCat
2016-01-13 15:42:52 +08:00
> es5-shim.js and es5-shim.min.js monkey-patch a JavaScript context to contain all EcmaScript 5 methods that can be faithfully emulated with a legacy JavaScript engine.
shim 完美模拟了所有 ES5 中可以被完美模拟的方法。有点绕,就是说 ES5 中有些方法,是可以在旧 JS 引擎中完美模拟了,那么 shim 就完美模拟了它们。
> es5-sham.js and es5-sham.min.js monkey-patch other ES5 methods as closely as possible. For these methods, as closely as possible to ES5 is not very close. Many of these shams are intended only to allow code to be written to ES5 without causing run-time errors in older engines. In many cases, this means that these shams cause many ES5 methods to silently fail. Decide carefully whether this is what you want. Note: es5-sham.js requires es5-shim.js to be able to work properly.
这一段别看这么多,核心意思就是 ES5 中其他无法被完美模拟的方法,就由 sham 承包了。 sham 只承诺你用的时候代码不会崩溃,至于对应的方法是不是起作用它就不保证了,它只是尽力模拟(as close as possible)
所以如果你要用的方法在 shim 中都包含了,那么就不需要 sham 。 sham 能不引用就不引用。但是如果你要用的方法只包含在 sham 中,那你要明白 sham 只是保证不崩溃,并不能保证对应方法的功能正确。
另外 sham 依赖 shim