Our approach. In our Javascript implementation we propose
a different approach that keeps the code small and speeds up
encryption/decryption. Instead of embedding tables in the
code, our library contains code that precomputes all tables
on the browser before encryption or decryption begins. Since
code to precompute the tables is much smaller than the tables
themselves, we keep the library size small. We reap the benefits
of precomputed tables by quickly building the tables on the
browser before the first encryption. The only values we hardcode
are the 10 round constants, which are 28 bytes total.
Precomputing the tables takes about 0.8ms on Google Chrome and about 8ms
on Internet Explorer 8. Because this saves several KB of code,
it is nearly as fast to precompute the AES tables as it would
be to load them from disk. Moreover, computing the tables in
the browser is far faster than downloading them over the network.
Another way to think of it: because tables used in encryption algorithms are often very difficult to compress with conventional algorithms, deriving the tables from their pre-compute algorithms is a much more efficient means of compression.