Not planned Add XF core JS to templating system

S Thomas

Well-known member
Adding the XF core JS to the templating system would essentially allow us to modify the JS in any possible way.
Reasons:
  • Right now we have to override core functionality if we want to make changes to something deep in between an instruction. Template modifications work everywhere and are non-destructive (if used properly).
  • It could lower the amount of requests from 3rd party addons by bundling changes to the core into <xf:corejs />.
  • It could lower the amount of requests from 3rd party addons by (semi-)automatically bundling 3rd pary scripts into one like $cssUrls does.
  • Easier to export.
Positive side-effect, versioning for everyone included.
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Negative side-effect: no browser caching. When the amount of JS gets to half a MB or however much it is, browser caching is important.

Another negative side-effect: pages rendering slower because rather than being able to optimise JS instructions by loading a whole file, browsers have to parse the entire document to find out where the end of the script tag is before the script can be compiled into machine code for execution.

I for one would be opposed to this suggestion for these reasons.


Fillip
 
We've discussed this kind of thing a few times.

Certainly something we don't want to do is do automatic concatenation of the JavaScript. Aside from the point that HTTP/2 actually handles multiple smaller requests better than single larger requests, bundling JS in together actually reduces cacheability of the content which overall is a net negative.

The editability of the code directly is an interesting idea, but unfortunately that has major side effects too. Imagine the quagmire that would be conflicting template modifications on JavaScript, merging JavaScript changes when templates become outdated and we'd either have to serve the full JS or minify at save time or on the fly which doesn't seem ideal.

This is why the JavaScript is designed to be extended as it is in our framework. You can monkey patch the code or overwrite functions directly and call the original function to add / change behaviours.

I don't normally like shutting suggestions down, so early, but it is something we've put a lot of thought into especially while developing XF2 and ultimately, it's not a route we want to go down.
 
Back
Top Bottom