I notice no bundle size difference between:
import { WebAuth } from 'auth0-js'
and
import auth from 'auth0-js'
I get a final bundled size of 30.52kB. I suppose there could be a problem with my setup.
Could you consider adding guidance on how to implement tree shaking, or at the very least note which imports are available. All the docs I've seen so far simply import the default export.
You won't notice any improvements because most of our dependencies are not three shaked either. Also, WebAuth imports pretty much everything else (except Management), so it's the biggest export we have.
We're exporting correctly (https://github.com/auth0/auth0.js/blob/master/src/index.js), but still need to work on actually using three shaking inside the library.
It would be really helpful if I could just import what I need. I literally construct an instance of the class and then use three methods. 30kB seems insane for my use case, and I imagine mine is pretty common.
@NathanielHill what methods do you use?
@luisrudge I'm using authorize, parseHash, and checkSession
@NathanielHill then you'll love the secret project that we're working on π I'll keep you posted. Can I reach out to the email address in your profile?
@luisrudge Sure.
I've considered just implementing those methods myself, can't imagine it would take more than a kilobyte or two..
Most of the size is actually because of parseHash, which uses the idtoken-verifier package: https://bundlephobia.com/result?p=idtoken-verifier
Which is using superagent which gives me tons of SSR warnings during development.
Is parseHash actually sending another network request to verify the token?
That doesn't seem completely necessary. If the site I'm redirecting to is compromised, seemed like it's already game over. Can it verify locally? I think jsonwebtoken is like 7kB
it does a request if your id_token uses the RS256 algorithm, since it needs to fetch the public keys here: https://{tenant}.auth0.com/.well-known/jwks.json (example: https://brucke.auth0.com/.well-known/jwks.json)
Seems like an argument for HS256 to me. Superagent is a killer right there. There are fetch solutions on the order of half a kB. Seems idtoken-verifier is the low hanging fruit
You can't verify HS256 tokens from single page applications though, that's why we issue RS256 tokens for this type of clients.
We have plans to migrate away from superagent in both idtoken-verifier and auth0.js, we just have other priorities right now (the super secret project β’οΈ I mentioned before).
Glad I'm at least not using auth0-lock... 18 levels of <div>s to get to a button!

what can I say? we love divs π
Hope you've got an accessibility expert on hand for that. I pity the screen reader that's gotta parse it
I just tested replacing superagent by unfetch, but unfetch requires a promise polyfill, so the end result is not THAT impactful:
βββββββββββββββββββββββββββ¬ββββββββββββ¬ββββββββββββ
β File β Size β GZIP size β
βββββββββββββββββββββββββββΌββββββββββββΌββββββββββββ€
β idtoken-verifier.js β 144.40 kb β 35.02 kb β
βββββββββββββββββββββββββββΌββββββββββββΌββββββββββββ€
β idtoken-verifier.min.js β 50.24 kb β 17.01 kb β
βββββββββββββββββββββββββββ΄ββββββββββββ΄ββββββββββββ
βββββββββββββββββββββββββββ¬ββββββββββββ¬ββββββββββββ
β File β Size β GZIP size β
βββββββββββββββββββββββββββΌββββββββββββΌββββββββββββ€
β idtoken-verifier.js β 120.29 kb β 29.29 kb β
βββββββββββββββββββββββββββΌββββββββββββΌββββββββββββ€
β idtoken-verifier.min.js β 41.73 kb β 14.90 kb β
βββββββββββββββββββββββββββ΄ββββββββββββ΄ββββββββββββ
We'll evaluate the change anyway, feel free to follow the PR here:https://github.com/auth0/idtoken-verifier/pull/27
Are there any easy wins for people using WebAuth in 2020?
Currently I'm just using:
These is all we use after customizing our universal login page using parcel, svelte, and auth0-js, with pretty good results.
I inline all the code so I can paste it into the editor, which is 146KB raw and 44KB gzipped.
would also like to hear/know more about the super secret project. I am in the same situation as @NathanielHill and it seems a bit overkill for a couple of methods that I use.
Has anyone been able to cut off the size of auth0.js?
Most helpful comment
Are there any easy wins for people using WebAuth in 2020?
Currently I'm just using:
These is all we use after customizing our universal login page using parcel, svelte, and auth0-js, with pretty good results.
I inline all the code so I can paste it into the editor, which is 146KB raw and 44KB gzipped.