dragome/dragome-sdk

Replacing JQuery with a micro library for XHR

Closed this issue · 18 comments

I really need the ScriptHelper to call some external JavaScript methods and get their return value. Are there any examples or documentation on how to use it? Also we use our own javascript UI library and do not really need the jquery. Can we leave it out during compilation?

Great thanks a lot. I added another quick question to my original post. We use our own javascript UI library and do not really need the jquery. Can we leave it out during compilation?

Jquery is used mostly for ajax calls and also for remote debugging via jquery-atmosphere extension.
I'd like so much to quit jquery dependency mostly cause its very small, there are some tests to do in order to accomplish this.

Making JQuery optional would be a great deal for us.

I think that making optional for ajax is not that far, but debugging using websockets without it is pretty difficult I believe.

Would it be logical to make it mandatory for debugging, but optional for production?

In case of jquery.atmosphere.js we can make it happen easily, but not with jquery.js

If only Ajax is used with JQuery, it should be trivial to write those routines. Any pointers to where the Ajax routines are used from JQuery?

yes, its usage is centralized in helpers.js

I can write those in pure JavaScript in this month, and submit it as PR if that is okay with you.

it would be great! take into account there are several usages of ajax services in helpers.js (get, post, jsonp), and each one is important to make dragome works.

I will try to meet these requirements. Do you have generators in Dragome for meta programming similar to GWT? I see a Generator class but it is not used anywhere else but one class.

JSONP will not work with XHR(Ajax). Cross site scripting is only allowed using script tag. It used to work with XHR with some hacks but it was long time ago. CORS on the other hand is something else. It needs server setup to make it work with XHR. I have found a micro XHR library which could replace JQuery. https://github.com/toddmotto/atomic. It is only 2KB and will do all needed. We can add CORS to this library with a couple of line of code.

Atomic looks great, simple and easy to use.
About generators, dragome can use any bytecode instrumentation tool for metaprogramming, in fact it's using javaflow for continuation in callback-evictor module, an asm based own tool for converting invoke-dynamic bytecode to previous JVM bytecode, and JsDelegateGenerator factory for creating bridges between java interfaces and js libs.
What kind of meta programming you want to do?

I was thinking about pre scanning the annotations and create some additional files (such as xml files, html files etc) using a generator, however I think that can be done using DragomeConfigurator if the suggested feature #78 is implemented.

I will add a simple code to the dragome runtime instead of using atomic probably this week. With the server version of qooxdoo (50K) and minus jquery, I think Dragome will take a breath.

https://github.com/bertung/dragome-sdk/blob/master/dragome-web/src/main/resources/js/helpers.js

The code is not yet fully tested. Left the old code in there for now. After testing it, will submit a PR.

The JQuery has been removed from Dragome.