api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

$.getScript is missing a signature

Open oriadam opened this issue 8 years ago • 4 comments

jQuery 1.12.0 added a signature for passing an options object to $.getScript. The options are padded on to $.ajax.

  1. The signature should be added to the docs
  2. In the Examples section, if you want to enable browser caching it is recommended to add a new function. This is not a good practice, and since 1.12.0 there is no use for it. One can simply:
    $.getScript({
        url: "foo.js",
        cache: true
    })

The above example should be added to the examples section, for jQuery 1.12.0 or later.

https://api.jquery.com/jquery.getscript/

oriadam avatar Jul 05 '17 12:07 oriadam

Thanks for the report. Would you like to submit a PR?

mgol avatar Jul 05 '17 13:07 mgol

Created PR 1054

oriadam avatar Jul 05 '17 15:07 oriadam

Looking into it now, I think this signature is still not supported. It only works by accident due to changes in jQuery.get. I'm not opposed to support that but we'd need unit tests ensuring it works merged to the jQuery repository first.

Would you open an issue there to discuss adding official support? Once it's accepted, we would accept a PR.

mgol avatar Jul 26 '17 09:07 mgol

Sure, opened the issue: https://github.com/jquery/jquery/issues/3736

The code looks good, doesn't look like accident. It makes a lot of sense too, similar to other ajax APIs that accepts the options object.

oriadam avatar Jul 26 '17 13:07 oriadam