-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Simplify $.ajax parsing using a link element #1875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Will you accept a patch that uses |
So nice to see this disapear! \o/ |
@jaubourg - were you responding to my question? :) If so, is that a yes? |
@phistuck, I was just sharing my happiness regarding the disappearance of the regexp. Using the URL API is a good idea though but we'd probably need to wait for all supported browsers to implement it (I haven't checked if they all do right now). The general consensus is to avoid multiple code paths, especially for small, non-critical, parts of the code like this one. |
@jaubourg - AJAX is used very frequently and the cost of creating an element in terms of memory (and possible garbage collection issues in the engine) is pretty big, compared to the URL constructor. Looks like everyone but Internet Explorer supports it. |
Well, this piece code is only executed once, not at each request. I agree it's a small change but I fail to see how critical it is. It seems rather logical to just wait for our support grid to only contain browsers that implement the URL object before simply switching to it. I don't speak for the team though but that's my take on it. |
During review of #1880 we discussed this but my take at the time was that it wasn't critical. Creating a link element a few times a second shouldn't be a perf or memory problem should it? |
My bad, I hadn't scrolled enough to see it used in the ajax code proper :/ Still, I agree with Dave, perf is not an issue here. |
Performance (in terms of speed) is less of an issue, but memory usage and failing to free the memory (the old Internet Explorer bug, for example) are concerning. Creating an element is a pretty big hammer and if you can avoid it with exactly the same interface, I do not see why not. (But I understand your reasoning as well) |
Are you saying there's a memory leak that |
I am not saying that there is one now (I have not checked it). I just say that an element is a big hammer that is better used sparingly when you have other options and I mentioned that browsers did use to have problems with element references and leaks. |
If
It should but may not be. If there was a provable issue here I think we'd be more likely to change the code. |
Currently we use a relatively complex regex to parse the URL and determine same domain requests for choosing the correct transport. We culd use the trick of parsing the url via an
<a>
element. Should be less hassle and less code.The text was updated successfully, but these errors were encountered: