# Easier embedding

**URL:** <https://talk.observablehq.com/t/easier-embedding/2382>\
**Category:** Announcements\
**Created:** [September 14, 2019, 1:22am UTC](https://talk.observablehq.com/t/easier-embedding/2382 "2019-09-14T01:22:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [September 14, 2019, 1:22am UTC](https://talk.observablehq.com/t/easier-embedding/2382/1 "2019-09-14T01:22:39Z")

</div>

To make [embedding notebooks](https://observablehq.com/@observablehq/downloading-and-embedding-notebooks) more convenient, we’ve introduced a new feature that generates the code snippet you need to embed a cell in any web page.

To use, click **Embed code** on the named cell you want to embed:

 ![17%20PM](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/d/de58bfa7a2c7379de6645f3139ada5e7dab93872.jpeg)

Then copy-paste the provided code into your web page:

 ![44%20PM](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/3/3970fb77466c8096d236a2a99c9efdcac2268d5e.jpeg)

And that’s it. Let us know what you think! 🙏

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [September 14, 2019, 8:36am UTC](https://talk.observablehq.com/t/easier-embedding/2382/2 "2019-09-14T08:36:34Z")

</div>

- The description still reads: " Copy this code to embed this **notebook** in any web page.". Should be something like “cell”, “snippet” etc, although I’d be careful to phrase it in a way that can be understood without knowledge of Observable concepts (“section”?).
- I’d argue that the option should be present on unnamed cells, but disabled (perhaps with a title attr text that explains that only named cells can be embedded). Someone unfamiliar with Observable won’t have a clue what “named” cells are, especially if they return a DOM node.
- Midterm I’d love to see the option to select multiple cells for embedding.
- Can the embed option also be provided on the notebook level?
- Perhaps a default stylesheet could be included into the snippet (or added as an option to the embed dialog)?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [September 16, 2019, 9:23pm UTC](https://talk.observablehq.com/t/easier-embedding/2382/3 "2019-09-16T21:23:14Z")

</div>

Fantastic! It would be cool to set min-height to something meaningful (by default), so we can try and avoid a flash. I know it’s impossible to know in advance what the final height will be (and it can even change…), but 0 is definitely wrong 🙂

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [September 16, 2019, 9:36pm UTC](https://talk.observablehq.com/t/easier-embedding/2382/4 "2019-09-16T21:36:03Z")

</div>

It can also be useful to add a link to the inspector CSS  
`<link href="https://cdn.jsdelivr.net/npm/@observablehq/inspector@3/dist/inspector.css" rel="stylesheet"/>`

---

<div class="post-metadata">

**Author:** ![maliky](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/maliky/32/706_2.png) [@maliky](https://talk.observablehq.com/u/maliky)\
**Post date:** [September 20, 2019, 9:43am UTC](https://talk.observablehq.com/t/easier-embedding/2382/6 "2019-09-20T09:43:48Z")

</div>

If I’m not mistaken, there a few minutes latency between the update of the code in observable and the update of the code on [https://api.observablehq.com/](https://api.observablehq.com/)

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [September 20, 2019, 5:35pm UTC](https://talk.observablehq.com/t/easier-embedding/2382/7 "2019-09-20T17:35:49Z")

</div>

Per this thread: [Embedding multiple cells from notebook into a React App](https://talk.observablehq.com/t/embedding-multiple-cells-from-notebook-into-a-react-app/2404/) the code returned by this feature currently isn’t correct for `viewof` cells (I think it should contain `name === "viewof X"`, not `name === "X"`).

**Edit** : [fixed!](https://talk.observablehq.com/t/bug-embed-code-menu-item-is-incorrect-for-viewof-cells/2472/2)

---

<div class="post-metadata">

**Author:** ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)\
**Post date:** [September 20, 2019, 5:58pm UTC](https://talk.observablehq.com/t/easier-embedding/2382/8 "2019-09-20T17:58:56Z")

</div>

> [@maliky](#):
>
> If I’m not mistaken, there a few minutes latency between the update of the code in observable and the update of the code on [https://api.observablehq.com/](https://api.observablehq.com/)

Yes, there’s currently a 30 second cache — so you may have to wait up to half a minute to see the latest published version of your notebook.

---

<div class="post-metadata">

**Author:** ![maliky](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/maliky/32/706_2.png) [@maliky](https://talk.observablehq.com/u/maliky)\
**Post date:** [September 20, 2019, 10:48pm UTC](https://talk.observablehq.com/t/easier-embedding/2382/9 "2019-09-20T22:48:06Z")

</div>

Ok, thank you for the clarification.

Also, newbies like me, to the node (or javascript in general) world should remember to clear yarn’s cache when doing some development.
