# Observable Cell Behavior for yield-ed vs return-ed animated svg element

**URL:** <https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590>\
**Category:** Help\
**Created:** [September 18, 2021, 10:32am UTC](https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590 "2021-09-18T10:32:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarioDelgadoSr](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mariodelgadosr/32/1828_2.png) [@MarioDelgadoSr](https://talk.observablehq.com/u/MarioDelgadoSr)\
**Post date:** [September 18, 2021, 10:32am UTC](https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590/1 "2021-09-18T10:32:01Z")

</div>

Reproduction: [SVG Yield vs Return / Mario Delgado / Observable](https://observablehq.com/d/b29f4def427561f7)

Please explain why:

- svg1 is re-rendered when referenced again in a cell
- svg2 is **not** re-rendered when referenced again in a cell

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/hellonearthis/32/3935_2.png) [@hellonearthis](https://talk.observablehq.com/u/hellonearthis)\
**Post date:** [September 18, 2021, 9:29pm UTC](https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590/2 "2021-09-18T21:29:25Z")

</div>

Not sure why, but if you make an HTML cell it updates the SVG element

```auto
${svg2}

```

---

<div class="post-metadata">

**Author:** ![abitrolly](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/abitrolly/32/7214_2.png) [@abitrolly](https://talk.observablehq.com/u/abitrolly)\
**Post date:** [September 19, 2021, 7:23am UTC](https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590/3 "2021-09-19T07:23:12Z")

</div>

In short, when you write a variable in a cell, you’re not just defining or referencing it like in plain linear JavaScript or Python, you are attaching it to the DOM. So when a variable is already attached and you make a cell with it a second time, Observable does not try to reattach the var or duplicate it. It invokes Inspector to show var type and content.

This is a dynamic Observable feature that I don’t think is explained anywhere except in this notebook by @mootari.

> **[Inspector Spinner 🕵️](https://observablehq.com/d/529808f2ee21ecf4)**
>
> Part 1: Observable's Inspector Any cell output gets passed through Observable's Inspector. The Inspector is responsible for displaying simple stuff like \`name = "foo"\` in a cell output, but also more complex representations like expandable arrays and...

Maybe the inspector should also hint at the bottom of its output that “the variable is already attached (here), see (docs)”. That would make this feature more self-discoverable.

---

<div class="post-metadata">

**Author:** ![MarioDelgadoSr](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mariodelgadosr/32/1828_2.png) [@MarioDelgadoSr](https://talk.observablehq.com/u/MarioDelgadoSr)\
**Post date:** [September 19, 2021, 4:12pm UTC](https://talk.observablehq.com/t/observable-cell-behavior-for-yield-ed-vs-return-ed-animated-svg-element/5590/4 "2021-09-19T16:12:46Z")

</div>

Very helpful discussion in the notebook. It’s share-able and not officially published yet, so I’ve added comments suggesting that @mootari publish it so it will show up in searches.
