textpattern icon indicating copy to clipboard operation
textpattern copied to clipboard

Modualise dev JavaScript and use JShint and Uglify for linting and minimising to production

Open philwareham opened this issue 7 years ago • 6 comments
trafficstars

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 avatar Mar 05 '18 13:03 philwareham

@philwareham - OK to defer to 4.9 at this stage?

petecooper avatar Nov 28 '19 13:11 petecooper

Yep - done that now

philwareham avatar Nov 28 '19 14:11 philwareham

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).

Bloke avatar Mar 02 '21 11:03 Bloke

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.

philwareham avatar Mar 02 '21 12:03 philwareham

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.

Bloke avatar Oct 17 '22 09:10 Bloke

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.

bloatware avatar Oct 19 '22 07:10 bloatware