-
Notifications
You must be signed in to change notification settings - Fork 2
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
Preload the application assets and cache connections #75
Conversation
48417e9
to
baabf8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, once that endpoint is out; thanks! This'll really help load times on embedded marketplaces!
src/lib/init.ts
Outdated
* assets (css, js, fonts, etc.) into browser cache. Subsequent | ||
* calls, use existing connections and cached assets. | ||
*/ | ||
if (options.preload) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we're making this configurable? Seems like it should just be the behavior of init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it for possible performance issue from the consumer, although this isn't render blocking it does't it does defer the dispatch of the main pages on-load event until after its own on-load event is dispatched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. If you think making this configurable is potentially helpful I'm game for it. However, optional properties with true
defaults aren't ideal. Can you change this to skipPreload?: boolean
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, doing now.
c48fc6f
to
bc155cb
Compare
bc155cb
to
de010f1
Compare
Issue:
We need a method to pre-load assets and connections when making calls within the embedded SDK.
Tried Solutions:
dns-prefetch
: Unnecessary because DNS resolution to obtain the cached IP address has already been done.preconnect
: Establishing apreconnect
from the top frame origin for resources referenced in the iframe will not function properly due to the differing origins between the top frame and the iframe.preload
: This method only preloads specified resources, which is ineffective for our case since our resources are bundled with different hashes. To make this work, we would need to create a remote-fetchable manifest that references these resources. This approach does not seem worthwhile.prerender
: Deprecating in Chrome and Edge, and already deprecated in Safari and Firefox.prefetch
: Only applicable for same-origin resources.**Solution: **
Develop a publicly accessible
embedded
route which is initially blank but contains all the necessary assets (css, js, fonts, etc.) for caching. The connections are also shared among iframe origins. I confirmed that the assets are all the hashed the same, as you navigate the application.Lifecycle of the Embedded:
/embedded
.