You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @johackim thanks for opening an issue. I haven't investigated @mdx-js/runtime could you share a little more info on how it might differ from @mdx-js/mdx
The other thing I've been thinking is that all MDX Embed components rely on the Intersection Observer. E.g when a component enters the viewports the child embed script is loaded. Intersection observer is a browser API so it might be that the components are being passed correctly but they won't load because the intersection observer never enters the viewport. Does that make sense?
Thanks for the update. One thing we could do... and this will probably be part of the ongoing global config work is to allow some kind of config option to turn the intersection observer off. By default it should use intersection observers because this is what keeps MDX Embed "polite" but I guess there's no harm in turning this functionality off if required. I might be able to slip in a quick update that exposes an optional prop on a component that will do a similar thing.
Is there any single component you urgently need? Perhaps I could make a change to just the Tweet component and release an -alpha version for you to test with?
I just ran into this problem one as well. I am using NextJS to update my blogs and migrate off of WordPress. Sometimes the embedded Tweets show up, others times they don't. It seems like the General Observer does not consistently fire. If I refresh the page, the Tweet always loads. However, if I navigate to a page a second time, the General Observer never loads. Though, I can trick it into loading again by scrolling down and then scrolling up.
Barring fixing the logic so that the General Observer always fires properly, I would definitely advocate for a "don't lazy load this embed option".
// simple example<TweettweetLink="bernhardsson/status/1605357323643506695"lazyLoad={false}/>// or taking inspiration from the <Script> tag// This seems to be the default now?<TweettweetLink="bernhardsson/status/1605357323643506695"loadStrategy="lazyInViewport"/>// Some new options<TweettweetLink="bernhardsson/status/1605357323643506695"loadStrategy="lazyOnload"/><TweettweetLink="bernhardsson/status/1605357323643506695"loadStrategy="afterInteractive"/><TweettweetLink="bernhardsson/status/1605357323643506695"loadStrategy="beforeInteractive"/>
Activity
PaulieScanlon commentedon Mar 20, 2021
Hey @johackim thanks for opening an issue. I haven't investigated
@mdx-js/runtimecould you share a little more info on how it might differ from@mdx-js/mdxjohackim commentedon Mar 20, 2021
Hello @PaulieScanlon ! Thanks for your response :)
I use
@mdx-js/runtimedirectly with nodejs. I build a cli tool to convert markdowns with mdx components to html.johackim commentedon Mar 22, 2021
Hello @PaulieScanlon, here a codesandbox to demonstrate the problem : https://codesandbox.io/s/mdx-embed-99hnm
PS: I remove @mdx-js/runtime, in fact, it's not a part of the issue.
[-]mdx-embed with @mdx-js/runtime return empty component[/-][+]mdx-embed return empty component[/+][-]mdx-embed return empty component[/-][+]mdx-embed return empty components[/+]PaulieScanlon commentedon Mar 23, 2021
@johackim could it be related to this?
mdx-js/mdx#558
The other thing I've been thinking is that all MDX Embed components rely on the Intersection Observer. E.g when a component enters the viewports the child embed script is loaded. Intersection observer is a browser API so it might be that the components are being passed correctly but they won't load because the intersection observer never enters the viewport. Does that make sense?
johackim commentedon Mar 27, 2021
@PaulieScanlon,
Yes you're right, the isChildVisible is set to false by default and it is never set to true when used with nodejs (no browser).
PaulieScanlon commentedon Mar 30, 2021
Thanks for the update. One thing we could do... and this will probably be part of the ongoing global config work is to allow some kind of config option to turn the intersection observer off. By default it should use intersection observers because this is what keeps MDX Embed "polite" but I guess there's no harm in turning this functionality off if required. I might be able to slip in a quick update that exposes an optional prop on a component that will do a similar thing.
Is there any single component you urgently need? Perhaps I could make a change to just the Tweet component and release an -alpha version for you to test with?
johackim commentedon Apr 5, 2021
No, there is no urgent for a single component, a global config option to turn the observer off seems to be a good idea, I will wait for this update :)
Thanks @PaulieScanlon
PaulMest commentedon Feb 2, 2023
I just ran into this problem one as well. I am using NextJS to update my blogs and migrate off of WordPress. Sometimes the embedded Tweets show up, others times they don't. It seems like the General Observer does not consistently fire. If I refresh the page, the Tweet always loads. However, if I navigate to a page a second time, the General Observer never loads. Though, I can trick it into loading again by scrolling down and then scrolling up.
Barring fixing the logic so that the General Observer always fires properly, I would definitely advocate for a "don't lazy load this embed option".