Bug 866088 - Use the shared LazyLoader to insert scripts

Also cache a few lengths lookups