mmd icon indicating copy to clipboard operation
mmd copied to clipboard

Use ES6 to further shave bytes

Open m90 opened this issue 9 years ago • 3 comments

Just because we can: using ES6 gives us AMD in 90 characters :octopus:

Runs in latest Chrome an Firefox and should probably never be used.

m90 avatar Sep 22 '16 18:09 m90

Nice :) But what about ES5 environments?

alexlawrence avatar Sep 29 '16 08:09 alexlawrence

That's why it doesn't make too much sense unfortunately. Let's wait another 10 years until we have forgotten what bundlers are....

m90 avatar Sep 29 '16 19:09 m90

How about this:

try{eval('define=(a,b,c)=>{define[a]=require(c?b:[],c||b)},require=(a,b)=>b(...a.map(c=>define[c]));')}catch(e){throw 'No ES6'}

It´s again 127 characters but it degrades gracefully (somehow).

alexlawrence avatar Oct 05 '16 09:10 alexlawrence