This repository has been archived by the owner on Feb 5, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use jQuery's standards-compliant promises.
Adds compatibility with jQuery 3.x.
- Loading branch information
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Why exactly do you use jQuery in a browser? Isn't this annoying for Web apps that do not use jQuery?
I had some difficulties as well, but adding follow-redirects to the browserify rules in package.json seemed to do the trick: https://github.com/linkedconnections/client.js/blob/master/lib/http/BrowserHttpFetcher.js
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be sufficient though.
Should I migrate?
Perhaps.
http
library.BrowserHttpFetcher
andNodeHttpFetcher
for my taste (but this is fixable).4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would indeed migrate away from jQuery if it's only for the ajax call.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RubenVerborgh does not work with https at this moment, but easy fix
Mind that the latest version of browserify uses stream-http as a HTTP drop-in. The library seems pretty lightweight and checks whether the browser has 'fetch' support, which is a streaming HTTP interface in e.g., chrome and Firefox. It looks in fact like it would not be too much overhead? @RubenVerborgh was the initial reason for not using the standard browserify drop-in?
Furthermore, in this library, you will now also get access to the URI that was requested after redirect. Which is a good thing for creating applications where the metadata can be found by looking up the document's URI as a subject in the list of triples.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size of stream-http seems considerable for the limited functionality we use. (So is jQuery, I know, but much more likely to be reused.) Will investigate size impact.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Node
http
library in the browser increases the gzipped filesize from 69kB to around 84kB (given that it depends on the Node.jsstream
library, which we don't need otherwise). An 18% increase in size, that doesn't add any functionality except for jQuery-independence, might be rather large.Granted, jQuery is around 75kB gzipped, but it comes with useful features. Interestingly, only including the AJAX part of jQuery would lead to a similar increase, so that's always an option.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting analysis! I've opened an issue in stream-http to see whether the owners see possibilities to optimize size: jhiesey/stream-http#45
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also been looking for a request library that:
I haven't found it yet.
Two possibly solutions I haven't investigated fully:
I'll be interested to see which solution ends up being selected here!
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting us know, @ariutta. My experiences (after a much shorter evaluation) were similar and lead us to write the current platform-specific wrapper around existing bits of code.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it a little more, I'm not sure whether IE9 can really support streaming, because it doesn't support XMLHttpRequest advanced features, including
progress
events. It might be possible to do something using XDomainRequest, but that's probably a waste of time.This library is browser-only, but it looks pretty good for cross-browser handling of chunked-transfer encoded responses.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried out a test case of patching superagent to allow for using chunked responses in a web worker. It's rough and not well tested, but you can check it out here.
Size 15kB minified, reduced further to 4.6kB when gzipped.
4dc3e19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying the switch to XMLHttpRequest in f323fe9.