# Value sent on outgoing port not received on first render

**URL:** <https://discourse.elm-lang.org/t/value-sent-on-outgoing-port-not-received-on-first-render/3931>\
**Category:** Learn\
**Created:** [July 4, 2019, 1:05am UTC](https://discourse.elm-lang.org/t/value-sent-on-outgoing-port-not-received-on-first-render/3931 "2019-07-04T01:05:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Libbum](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/libbum/32/1311_2.png) [@Libbum](https://discourse.elm-lang.org/u/Libbum)\
**Post date:** [July 5, 2019, 9:40am UTC](https://discourse.elm-lang.org/t/value-sent-on-outgoing-port-not-received-on-first-render/3931/3 "2019-07-05T09:40:12Z")

</div>

> [@curiouslearn](#):
>
> Is there a DOMContentLoaded on Elm, so that I can send the value after the DOM is loaded and ready to go?

Not officially AFAIK. Could you give me a rework of your code with this new implementation?

If I understand what you’re saying I think its a similar problem to what I’ve come across already.  
Take a read of this thread:

> [@requestAnimationFrame problem when using --optimize](https://discourse.elm-lang.org/t/requestanimationframe-problem-when-using-optimize/2885):
>
> I’m doing some stuff with D3 and sending updates through ports. One port is having issues when I compile with --optimise—it works fine in debug mode however. I need D3 to select the #map div and do work on it, but this is rendered in my View, so I use requestAnimationFrame to make sure the View is rendered before starting the D3 commands: port drawMap : () -\> Cmd msg app.ports.drawMap.subscribe(function() { requestAnimationFrame(function() { drawMap(); }); return null;…

There’s currently no nice solution to this one either. I’ve kept the [wait for element](https://github.com/Libbum/Odyssey/blob/1e641075658b00ad293862b81265f6bfe16910ea/src/init.js#L280-L289) implementation in my solution. So that’s not too different from an arbitrary sleep.

---

_[View the full topic](https://discourse.elm-lang.org/t/value-sent-on-outgoing-port-not-received-on-first-render/3931)._
