?
avatar C-Lodder
C-Lodder
7 May 2020

Summary

The Joomla.request() method that executes an XHR request current supports 2 callback methods:

  • onSuccess
  • onError

There needs to be a callback method that executes regardless or whether or not the request failed

Solutions

  • Return a promise. Either using promises or make it an async method (preferable)
  • Add an onComplete callback method
  • Deprecate Joomla.request() and suggest using fetch()
avatar C-Lodder C-Lodder - open - 7 May 2020
avatar joomla-cms-bot joomla-cms-bot - change - 7 May 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 May 2020
avatar C-Lodder C-Lodder - change - 7 May 2020
The description was changed
avatar C-Lodder C-Lodder - edited - 7 May 2020
avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

Just use fetch()
Also drop the unneeded wrapper around the Events in the same file

PS can't be done without a proper way to patch the missing pollyfil for ES5

avatar C-Lodder
C-Lodder - comment - 7 May 2020

PS can't be done without a proper way to patch the missing pollyfil for ES5

If that's your thinking then both the backend and frontend templates should support IE11 too.
Casseopia CSS grid should be moved to BS grid.

avatar C-Lodder
C-Lodder - comment - 7 May 2020

The media_source may aswell just be moved back to ES2013 and minified with terser...oh sorry, I mean UglifyJS.

avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

@C-Lodder it;'s not my thinking, it's called progressive enhancement and it's kinda the industry standard. Saying let's use X-Y-Z without any thoughts about older browsers is the path that will get Joomla to 0% usage...

My 2c

avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

@C-Lodder also it requires zero effort from the ES20XX to get to a fully functional ES5 script: use rollup, there job done!

avatar C-Lodder
C-Lodder - comment - 7 May 2020

kinda the industry standard

Erm, not, it isn't. There are many big players out there that have completely dropped support for IE11. Why? Because it holds back development.

also it requires zero effort from the ES20XX to get to a fully functional ES5 script

So why not just have Joomla ship es6.js files only and let devs transpile and use the necessary polyfills to get thier Joomla site working in IE11?

Of course it's possible, but why the hell do we need to ship ES5 in core?

Like I said, if Joomla needs to ship ES2013 JS, then it may aswell also replace its CSS vars and grid

avatar HLeithner
HLeithner - comment - 7 May 2020

es5 files should only be there for reference and use for Developer for easier use in ie11 usage scenario if needed.
Joomla Backend and Frontend is not bound to ES5. But 3rd party devs should be able to create a ES5 compatible templates. that's the reason the ES5 files exists.

I'm not sure if @wilsonge want's to ship them or only have them as reference for 3rd party.

avatar C-Lodder
C-Lodder - comment - 7 May 2020

@HLeithner So what if nobody out there develops a IE11 compatible template? Do they have to develop one themselves?

If the ES2015 JS is shipped to provide support for old browsers, then I don't see the CSS shouldn't support IE11. Either support it, or don't. It's pointless shipping something half baked for IE

avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

Of course it's possible, but why the hell do we need to ship ES5 in core?

Because in many countries (England is one of them, so I expected to be more conservative here) have a way too high percentage of IE usage.

And since I like to talk with actual figures, here is the official IE usage from your country's gov site:
https://twitter.com/TheRealNooshu/status/1247565222384218112

avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

@C-Lodder compiling and providing the script as I said before is a zero effort if the right tools are used. Seriously with my proposal (type=module/nomodule) there is no problem and we're using progressive enhancement the right way. I seriously don't get why we need to ditch something that effectively is automatically generated...

avatar C-Lodder
C-Lodder - comment - 7 May 2020

Because it's still holding the JS back.

  • Joomla doesn't even load ES6 files
  • I can't see anyone converting the JS to modules
  • We can't use newer DOM methods cause Joomla's build scripts don't even polyfill them.
avatar dgrammatiko
dgrammatiko - comment - 7 May 2020

Joomla doesn't even load ES6 files

Problem is that people have some short of problem with the defer attribute, you can load today ES6+ files even in Joomla 3.x, eg:
Screenshot 2020-05-07 at 19 57 08

I can't see anyone converting the JS to modules

To add type=module you don't have to do something special, the current scripts will works as they are

We can't use newer DOM methods cause Joomla's build scripts don't even polyfill them.

That's a limitation of the build tools. The scripts need to be processed by a bundler, then the polyfilling will also be transparent

Because it's still holding the JS back.

Mate, seriously have you seen what most Joomla devs ship on the js? Also patching the various jQuery dependant scripts will yield more performance than switching to delivering some files as ES6 but still loading jQuery and bootstrap.js

avatar brianteeman
brianteeman - comment - 8 Apr 2021

@dgrammatiko @Fedik is there anything to do here? Has it been resolved? Is it a non-issue?

avatar dgrammatiko
dgrammatiko - comment - 8 Apr 2021

Has it been resolved?

I agree with @C-Lodder here, fetch is a better native function but unfortunately we are fashionably late here to do anything before 4.0 stable. Probably a viable alternative is to introduce another core.js, let's call it core-js-api.js with modern functions and less code. That said I still have a couple of improvements in the pipeline: #32748 and #32747 but they don't seem to attract any attention so their fate is questionable...
In sort I guess we could open a discussion on what a modern core.js could be but not for 4.0 stable, there's no manpower to do the required work...

Anyways that's my 2c here

avatar Fedik
Fedik - comment - 9 Apr 2021

I think we can add onComplete callback. Maybe I will try to look sometime.

Introducing promise or replace to fetch will be b.c. However people already can use fetch in their own scripts.

avatar Fedik Fedik - change - 11 Apr 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-04-11 10:11:09
Closed_By Fedik
avatar Fedik Fedik - close - 11 Apr 2021
avatar Fedik
Fedik - comment - 11 Apr 2021

please test #33099 if still have an interest in it :)

Add a Comment

Login with GitHub to post a comment