Skip to content
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

[DOC] CDN version and browser variable #1269

Closed
reviewher opened this issue Sep 5, 2017 · 5 comments
Closed

[DOC] CDN version and browser variable #1269

reviewher opened this issue Sep 5, 2017 · 5 comments

Comments

@reviewher
Copy link

  1. The latest version is available on CDNs that pull from NPM, such as unpkg. Other comments have recommended using wzrd.in. Is there a "recommended" CDN? If so, it would be nice to mention somewhere in https://github.com/visionmedia/superagent#installation , with something like

browser:

<script src="https://unpkg.com/superagent/superagent.js"></script>
  1. The README vaguely references browser support but doesn't mention the fact that the actual variable is superagent! To follow along with the examples in the README, I had to add the line
var request = window.superagent;

There are two ways to fix the situation:

A) mention that the standalone script exports the superagent variable and recommend that browser users make the change in their code

B) rework the samples to use the superagent name instead (e.g. var superagent = require('superagent');)

I'd think B makes more sense given that there is an existing library called request

@kornelski
Copy link
Contributor

I don't have any recommended CDN. Personally, I prefer bundling with webpack. When you use webpack it's also clear what is the name of the import and there aren't any globals to worry about.

@reviewher
Copy link
Author

Does the library work without webpack, or is it an essential dependency?

@kornelski
Copy link
Contributor

kornelski commented Sep 6, 2017

We provide superagent.js compiled for web browsers in the npm package, so you can use it without having webpack or browserify yourself.

@reviewher
Copy link
Author

That makes sense @pornel but when using the superagent.js script the library is exposed as superagent, not request. That piece of information is not in the docs. Try to use that superagent.js script in a page and follow the README and you'll see the confusion.

In retrospect there are actually 3 ways this could be resolved: mention that browser users have to add var request = window.superagent; in the code, redo the documentation samples with the superagent variable name, or just change the library to directly assign to window.request

@niftylettuce
Copy link
Collaborator

v5.0.0 was just released to NPM and an updated README is now available here on GitHub (see https://github.com/visionmedia/superagent#superagent).

What's new

  • Browser version is now only 19KB (that's 60% in file size savings from v4.x which was 48KB)!
  • Codebase refactored using xo, prettier, remark, and more
  • Browser compatibility linting via eslint-plugin-compat
  • Browserslist integration (current targets are > 1%, last 2 versions, ie 9)

How to install

npm install superagent@latest

Or if you're using yarn:

yarn add superagent@latest

Polyfills

Please see the Required Browser Features section in the README if you plan to support IE 9 and/or IE 10 and use superagent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants