Future use of Fetch

6 views
Skip to first unread message

Glenn Thompson

unread,
Jun 2, 2020, 7:40:50 PM6/2/20
to cometd...@googlegroups.com
Hey,

The organization I work for is starting to telegraph that the use of jquery should be considered deprecated.  Although many portions of jQuery are in fact easily replaced by newer more standard practices, I'm not sure Ajax is one of them.  I'm being told that they want us to start using Fetch. Besides spotty support, I'm concerned that using Fetch for long polling may not be an option.
I have no problem with Jquery, its what I use from many things. 

However, going forward from a CometD perspective:

1. Is Fetch in the plans?
2. Would Dojo be lighter weight for the purpose of ajax only.
3. Or do something like angular did where they made jQuery light within the framework.

Thanks,
Glenn

Glenn Thompson

unread,
Jun 3, 2020, 10:32:35 AM6/3/20
to cometd...@googlegroups.com
I turned up a js library called Axios.  It doesn't use fetch but I think it looks like it may be an option for removing jQuery.  Any thoughts or recommendations are very welcome.

Simone Bordet

unread,
Jun 3, 2020, 12:06:11 PM6/3/20
to cometd-users
Hi,

On Wed, Jun 3, 2020 at 1:40 AM Glenn Thompson <gatma...@gmail.com> wrote:
>
> Hey,
>
> The organization I work for is starting to telegraph that the use of jquery should be considered deprecated.

jQuery should win an award for the JavaScript framework that lasted
more than 2 months!
:D

> Although many portions of jQuery are in fact easily replaced by newer more standard practices, I'm not sure Ajax is one of them. I'm being told that they want us to start using Fetch. Besides spotty support, I'm concerned that using Fetch for long polling may not be an option.
> I have no problem with Jquery, its what I use from many things.
>
> However, going forward from a CometD perspective:
>
> 1. Is Fetch in the plans?

No, unless it's convenient or mandatory to support it.

> 2. Would Dojo be lighter weight for the purpose of ajax only.

I don't know about "lightness" as there are so many other things to
take into account.

> 3. Or do something like angular did where they made jQuery light within the framework.

Again "light", not sure what that means in your context.

CometD is independent from jQuery.
If you want to remove jQuery, go for it.
You have a choice to use CometD from AMD, CommonJS or Vanilla, so
whatever JavaScript framework you want to use, CometD should be easy
to use.

If that's not the case, then let's discuss it, but so far since it
supports AMD and CommonJS, build-time tools like Browserify etc. will
optimize your JS files (and CometD with them).

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.

Glenn Thompson

unread,
Jun 3, 2020, 2:32:05 PM6/3/20
to cometd...@googlegroups.com
Thanks for the quick response Simone.

So correct me if I'm wrong but I have to include JQuery, Dojo, or Angular to allow CometD to make the http requests.  That's the only dependency of CometD on anything else. So I was mainly trying to see if you were going to support other libraries or "Fetch" out of the box.  I have looked through the code enough to see that adaptation to other libraries would not be monumental.  My management may hear a slightly different story however:-P

I agree on the jQuery front. 

As far as lightness is concerned, the argument I hear most is that using jQuery selectors provide no value given that they are now supported natively and as such they don't justify the size of the library given that selectors are often cited as the main plus.  As if there is no other value. Terribly broad I know.  So lightness would be the size of the library as compared to its usefulness.  However given the module point I think I'll just seek an exception should it come to that.  We are only just now allowed to use tools like browserify and webpack. So imagine the world of dysfunction I live in.  It took 3 months to get cometd approved:-)

Anyway, appreciate the response.  

I've been using a custom web jar I build on the fly from your wars. So I'll push to move to modules. That would make me happy anyway. This is an old app we have on life support.

Thanks again and sorry for the noise.

Glenn


--
--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users

Visit the CometD website at http://www.cometd.org

---
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cometd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cometd-users/CAFWmRJ3sdoMm1_kdRWK_%3DHc%3D5WitbSSkwBHnbSmKE%3D9v7ew0Uw%40mail.gmail.com.

Dustin Machi

unread,
Jun 3, 2020, 3:35:25 PM6/3/20
to cometd...@googlegroups.com
I think Dojo here would be fairly old and probably cause you headaches with  webpack/browserfy.  You could probably write a pretty lightweight js module based on fetch that can interact with CometD I’d think.  It has been a while since I’ve looked at the details of those libs in regard to cometd, but there isn’t anything magic about fetch.  It should be able to long poll fine:  https://javascript.info/long-polling

Dustin

Glenn Thompson

unread,
Jun 3, 2020, 3:43:48 PM6/3/20
to cometd...@googlegroups.com
Hey,

Yeah if I did try to write something I would try Fetch first and I would of course contribute back.

Thanks,
Glenn

Simone Bordet

unread,
Jun 3, 2020, 3:44:42 PM6/3/20
to cometd-users
Hi,

On Wed, Jun 3, 2020 at 8:32 PM Glenn Thompson <gatma...@gmail.com> wrote:
>
> Thanks for the quick response Simone.
>
> So correct me if I'm wrong but I have to include JQuery, Dojo, or Angular to allow CometD to make the http requests.

Not only.

CometD has a vanilla JavaScript HTTP transport based on
XMLHttpRequest, which is going to remain there forever even though
Fetch is also there.
I read Fetch has some limitations, though (especially for cross-origin
requests) so if that's true it may not be the best solution for
CometD.
However, XMLHttpRequest is there and it's working fine, so I think you
are good to go.
I don't think there is immediate pressure to use Fetch, if you have
XMLHttpRequest available.

I know people are using CometD with VueJS.
Pretty much any framework that works with CommonJS can use CometD, and
same for AMD.
Failing those 2, you can use the global namespace.

> That's the only dependency of CometD on anything else. So I was mainly trying to see if you were going to support other libraries or "Fetch" out of the box. I have looked through the code enough to see that adaptation to other libraries would not be monumental. My management may hear a slightly different story however:-P

I guess the question is then "ok for Fetch, but is it ok to use
XMLHttpRequest?" if the answer is yes, then you can use CometD.

Glenn Thompson

unread,
Jun 3, 2020, 4:25:52 PM6/3/20
to cometd...@googlegroups.com
I didn't realize there was a vanilla transport.  I'll look into that in more detail then.  The first time I used CometD back in 2.x days someone on my team attempted to extract out ajax code from jQuery and failed. We were dealing with techno-politics even back then:-)  In the end we just pushed back. 

Thanks everybody. 



--
--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users

Visit the CometD website at http://www.cometd.org

---
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cometd-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages