4 ms·
Why is this needed in the codebase? export const getFullYear = 'getFullYear'; export const getMonth = 'getMonth'; export const getDate = 'getDate';
by 3dfan 7y ago
Why is this needed in the codebase?
export const getFullYear = 'getFullYear';
export const getMonth = 'getMonth';
export const getDate = 'getDate';
export const getDay = 'getDay';
export const getHours = 'getHours';
export const getMinutes = 'getMinutes';
export const getSeconds = 'getSeconds';
export const getMilliseconds = 'getMilliseconds';
To be seen here:
https://github.com/leeoniya/uPlot/blob/master/src/fmtDate.js https://github.com/leeoniya/uPlot/blob/master/src/fmtDate.js
- leeoniya 7y agoit reduces code size. d.getHours();d.getHours(); cannot be compressed but d[getHours]();d[getHours](); can compress to d[a]();d[a](). do this enough times and you've saved 1kb. you should see the kinds of compression hacks the Preact team does ;)
- pintxo 7y agoDon't js compressors do this sort of optimization on their own?
- leeoniya 7y agoif you enable a bunch of unsafe options they can do some of them, but they tend to err on the safe side when it comes to native built-in methods like these on Date objects. also, some minifiers optimize for gzip size where the effect is not as drastic, but the browser still has to parse the un-gzipped source afterwards. it depends on the weighted costs built into each minifier.
- e12e 7y agoIs that relevant with gzip enabled for transport? I'm assuming (possibly wrongly!) that such hacks do little in terms of parsing speed/AST complexity. I suppose it's possible the js runtime might also benefit for some of these modifications?