legacy.js is a drop-in replacement for mini.js (added in
dcl 1.1.0), which supports legacy browsers (tested with IE8). It has the same API, and the same functionality.
This module is meant to be used as a substitute for mini.js. But there is one scenario when it can be used on its own: as the only
dcl module in a small project. In this case, when no other
1 2 3 4 5 6 7 8 9 10 11 12 13
for in loop bug, which skips some property names.
In general it means that the normal
for in loop:
1 2 3 4
Should be approximated like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Obviously such approximation is inexact, and more expensive space-wise, and processor-wise. This is why it was rejected initially. Later on a legacy version of mini.js was designed as a replacement, keeping the canonical version of
dcl small and fast, yet providing an option for legacy environments (older version of IE).
How can I substitute
First of all, you need to do it only in a browser environment. Over there an AMD loader will help us. For example,
tests\tests.html uses a conditional comment technique targeting legacy IE browsers specifically:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
You can see how the script manipulates
require.config to load
legacy.js instead of mini.js on IE < 9.
Read more about this technique in MSDN: @cc_on.
Can I just replace
legacy.js in my own IE-specific application?
Yes. But remember that when you handle 3rd-party files manually, you are on your own, and all mistakes are yours.
I built all my JS files into two layers: normal, and legacy. How can I load them conditionally?
One way to do it is to use HTML-level conditional comments supported by IE. Read more about this technique in MSDN: About conditional comments.
Does it work on IE6?
Unlikely – it was never tested on IE6, and so far no requests were made for such environment. But you can always try.
Gentle reader, be warned: IE6 had even more implementation bugs than IE7/IE8.