magiclabs / magic-js

Magic browser/React Native JavaScript SDK is your entry-point to integrating passwordless authentication inside your application.
https://magic.link/docs/api-reference/client-side-sdks/web
Apache License 2.0
454 stars 86 forks source link

Reduce unused javascript from assets.auth.magic.link #332

Open Royal-lobster opened 2 years ago

Royal-lobster commented 2 years ago

✅ Prerequisites

❓ Question

assets.auth.magic.link is taking majority of resources. is there a way to reduce unused bytes ?

CleanShot 2022-07-16 at 00 05 38@2x CleanShot 2022-07-16 at 19 47 31@2x

🌎 Environment

Software Version(s)
magic-sdk 8.1.1
Browser Google Chrome
yarn 1.22.19
Operating System Mac OS Monterey 12.4 (21F79)
kesar commented 1 year ago

it would be great if we can get this trimmed. its 50% of our request

ayv8er commented 1 year ago

Thank you for bringing this up Kesar. We'll be discussing this internally and I'll respond once we have an update.

kesar commented 1 year ago

Thank you for bringing this up Kesar. We'll be discussing this internally and I'll respond once we have an update.

thanks! we've built https://www.npmjs.com/package/@everipedia/wagmi-magic-connector and its starting to get a bit of traction, it would be amazing if we could reduce that bundle problem so pages don't get bad performance from google which impacts SEO 👍🏻

Let us know if you need any help from our side, we are happy to help!

kesar commented 1 year ago

any update on this? we might need to use a different auth provider if this does not get solved. It really affect to SEO and performance to have such a big bundle

kesar commented 1 year ago

anyone in the boat?

image

image

dgerrellsMagic commented 1 year ago

@kesar We support a plethora of blockchains and use code splitting to only deliver what is needed based on the SDK use case. Unfortunately, most blockchain libraries are not optimized for bundle size. Our authentication relies on Ethereum libraries for creating the DID tokens. There is some work that can be done to reduce the overall bundle size however the biggest offenders won't be trivial.

I do think the lack of Cache TTL can be addressed in the interim.

VirenMohindra commented 1 year ago

We're consistently failing lighthouse largely because of the magic library.

What is the best workaround to optimize the package so we can get faster load times?

kesar commented 1 year ago

We're consistently failing lighthouse largely because of the magic library.

What is the best workaround to optimize the package so we can get faster load times?

which we ended up doing its to dynamic load blockchain libs when user clicks in login, that way lighthouse gets better score

Frozies commented 1 year ago

We're consistently failing lighthouse largely because of the magic library. What is the best workaround to optimize the package so we can get faster load times?

which we ended up doing its to dynamic load blockchain libs when user clicks in login, that way lighthouse gets better score

@kesar Can you please go into more detail onto how you dynamically loaded the blockchain libs for magic? I need to do the same. I am using wagmi & everpedia connector too.