Wednesday, November 6, 2013

Removing dependency on jQuery

Recently I've been working on removing jQuery from pdf2htmlEX.js.

jQuery was initially introduced as a handy cross-platform JavaScript syntax. Until recently, I didn't realized that IE(>=9) had already implemented most standard JavaScript APIs. I was still thinking about attachEvent vs addEventListener at that time.

A few days ago when I was trying to optimizing JS code, I found jQuery is really large (~90K minimized), while all other js and css files are no bigger than ~10K in total. Also lots of results from jsperf.com show that jQuery is really slow.

Currently most jQuery functions have been replaced with standard JavaScript APIs, except for $.extend and $.ajax, which will be worked out soon. Another exception is Element.classList which is not implemented in IE9, but I've copied a JS snippet from PDF.js for that.

I can indeed feel a boost on performance after the removal of jQuery, but the modification is likely to cause regression, although I've checked caniuse.com for each API I used.  I've tested the code on Firefox/Chrome on Linux, and I'll test on others as well.

Target browsers:
- IE >= 9
- Recent versions of Firefox / Chrome / Safari

Please help test (the git version of) pdf2htmlEX with your browser and file bugs if any. Thanks!


No comments :

Post a Comment