known icon indicating copy to clipboard operation
known copied to clipboard

Javascript needs to be rewritten and namespaced

Open mapkyca opened this issue 8 years ago • 6 comments

While trying to do this:

Using lightbox plugin

I encountered this error:

Images didn't load

Some other notes:

Isolated this to the image.js Image() declaration causing some sort of namespace collision. I suspect this'll keep happening, so these libraries should be rewritten to use a namespace, or similar.

See:

https://appendto.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/

mapkyca avatar Oct 12 '17 14:10 mapkyca

There would be a lot to be said for moving to ES6, if we could.

benwerd avatar Nov 28 '17 14:11 benwerd

Aye, that's sort of what I'm thinking. I'm not a JS expert tbh, but Known doesn't have a great deal in the core files so shouldn't be too much of a pita

mapkyca avatar Nov 28 '17 15:11 mapkyca

Classes and modules would be interesting: https://webapplog.com/es6/

Browser support is the only big issue, we should take a view on that as and when.

mapkyca avatar Nov 28 '17 15:11 mapkyca

Swinging back to this - now minify is handled by Grunt, we could stick a babel task on prior to that to backport.

Any thoughts?

mapkyca avatar Aug 17 '18 08:08 mapkyca

If we want to stick using Grunt (and not Webpack), then I could check out this Grunt plugin and see how to move the Known JS code into modules first, then we can also refactor/upgrade to ES6: https://github.com/babel/grunt-babel

johanbove avatar Oct 06 '19 20:10 johanbove

I've already moved grunt over to using babel, and so we can write ES6.

So, I'd look at probably using classes and all that good stuff.

mapkyca avatar Oct 07 '19 09:10 mapkyca