adobe / helix-embed

Embed service for helix.
Apache License 2.0
5 stars 3 forks source link

Client Side Embeds #353

Closed trieloff closed 3 years ago

trieloff commented 3 years ago

The current system of server-side embeds has some distinct advantages for authors and developers:

but it also comes with marked disadvantages, namely

@davidnuescheler and @MarquiseRosier have been experimenting with client-side embeds, with promising results, but this approach has two shortcomings:

The following is a proposal for a unified approach that combines the best of both worlds:

As a result, authors will add embeds as before, and when requesting a page with an embed, following things will happen

  1. each embed in the Markdown will become a <a href="" class="helix-embed">
  2. the page will include an <esi:include src="/_hlx_embed/embed.js.esi"> at the bottom of the page
  3. this ESI will be replaced with <script src="/_hlx_embed/embed.js?version=${sha}">
  4. /_hlx_embed/embed.js?version=${sha} will be loaded by the browser and cached a long time
  5. the script will make a request for each <a href="" class="helix-embed"> and replace the link with an appropriate embed
tripodsan commented 3 years ago

I don't like that the contents of the embed.js is dictated by helix-static, nor that helix-pipeline injects HTML.

I would:

trieloff commented 3 years ago

I can understand the desire to override embed.js and we can add this ability to helix-static, too.

What speaks against adding the ESI to the pipeline?

tripodsan commented 3 years ago

I can understand the desire to override embed.js and we can add this ability to helix-static, too.

but if it's served from /scripts/embed.js it's automatically served from the correct place.

What speaks against adding the ESI to the pipeline?

people might have an opinion on the exact way how and when the script is loaded.

tripodsan commented 3 years ago
  • [ ] make a request to /_hlx_embed/${a.href} and retrieve a JSON metadata object

better: make a request to /_hlx_embed?src=${a.href} and retrieve a JSON metadata object

:-)

tripodsan commented 3 years ago

Basically in other words: if we just removed all the embed stuff from the pipeline (except adding <a href="" class="helix-embed">), then it can be easily handled in helix-pages today and no changes to helix-static are needed.

trieloff commented 3 years ago

Closing. We probably don't need this.