-
Notifications
You must be signed in to change notification settings - Fork 254
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
Make Frontity components AMP-aware #794
Comments
@SantosGuillamot Could you clarify this for me? Do we want to deprecate the |
I don't think we have to deprecate the |
Yes,
It's not only those lines, it's pretty much the whole component! 😄 Something along these lines: const Image = ({ loading = "lazy", ...props }) => {
const { state } = useConnect();
if (state.frontity.mode === "amp") return <amp-img {...props} />;
return <img {...props} loading={loading} />;
};
export default connect(Image, { injectProps: false }); The API (component props) can't change because it needs to be backward compatible.
The problem with the current component is that the image doesn't load until the hydration has finished, which means a very bad Largest Contentful Paint. |
ok, gotcha. Thanks guys! 🙂 |
I've read through those community posts:
and there are still some things that are not clear to me.
I think that the problem here is that we don't show the image until hydration: https://www.loom.com/share/ce5cf10b85fe49609f4cc8684da58b9d But I wonder what's the best thing to do here. I think we have 3 options:
@SantosGuillamot What do you think? |
Thanks for the explanation Michal 🙂 The initial idea was that, as we were going to work on the Image component for this feature, we could take the opportunity to remove the fallback of the IntersectionObserver which was causing some issues. The way I see it, I agree the option 2 would be a better solution, but as you mention it seems to be many extra work. I would go with the option 1 and treat the option 2 as a different Feature Discussion that could be address later. |
It's not that much the visibility of the image but the fact that the SSR'ed
Doing SSR with But thankfully we can remove that trickery now that native lazy load is present in modern browsers 🙂 |
This is needed for AMP feature. For full context please check out the final Implementation proposal.
The AMP framework uses a special syntax for the images, the iframes and the scripts, so we have to make Frontity components AMP-aware.
We can take this opportunity to remove the Intersection Observer fallback from the Image and Iframe components, that doesn't make sense anymore.
The text was updated successfully, but these errors were encountered: