textpattern
textpattern copied to clipboard
Modualise dev JavaScript and use JShint and Uglify for linting and minimising to production
The currently large single JavaScript file textpattern.js is unwieldy and makes dev harder. We need to split this down into it's components, modernise and clean up codebase, and then use tools such as JShint and Uglify to produce production code.
@philwareham - OK to defer to 4.9 at this stage?
Yep - done that now
Side note: when we refactor textpattern.js, is there mileage in considering replacing our jQuery usage with native JS - either wholesale or piecemeal? We touched on this quite a bit in #1398 so I won't reiterate here, but the crux of it is that since native JS is more capable now, has jQuery had its day in our code? Is JavaScript suitably advanced that we can effectively design out jQuery? Or is it still handy for the convenience of some of the things like Ajax calls?
If it's possible/desirable - I'm not suggesting we have to do it all on day one, or even replace it entirely - and we can use this opportunity to reduce our usage of the libraries jQuery and jQuery UI over time then they might one day be able to disappear. That's one or two fewer things to maintain and track, and fewer bytes transferred over the wire on each page load (cache/CDN notwithstanding).
Yes it would be better to use native JavaScript where possible I think, including for UI bits where we can (we need to audit what parts of jQuery UI are essential and possibly seek alternatives or write our own if jQuery UI stays practically abandoned).
I don't think we can completely ditch jQuery from inclusion any time soon though as I'd imagine a fair few plugins use it.
Is this something we feel we can tackle now? It'd be nice to have some neater framework in place for handling JS interaction. I'm not sure I have the coding chops for it, as JavaScript has moved on significantly with Promises and arrow functions and stuff.
Is retooling textpattern.js something you can spearhead please, @bloatware? I'll help where I can but I'm not sure where to begin, so if you have any thoughts on how to tackle this, it'd be most appreciated.
My js-foo barely suffices to patch the existing code, developing a new framework is beyond my skills. We'd need a clean base here to extend, suggestions welcome.