News for hackers. Stuff that matters.
Re:Building a Distributed Turn-Based Game System in Elixir by iudqnolq on Friday April 30, 2021 @12:12PM (#26995337)
Have you figured out any good way to have per-page javascript where the JavaScript is only sent over the wire for that pages?
Re:Building a Distributed Turn-Based Game System in Elixir by hnedeotes on Friday April 30, 2021 @01:15PM (#26996294)
From the top of my head not really, but this would depend on a few things:

- Is it a vendor lib ?

- It's not but is some particular file that is big enough to not make sense including on the root layout?

- It's neither, but functionality that can trigger multiple times and should be only once and only on those pages because it can conflict? or some variation of that?

I think they're all solvable but what makes sense will depend on those, but also on how you're using LiveView (is it LiveView only for logged-in users/some auth, can you set those on the live_view layout...)

But in some cases this is a problem also in spa's, where you have to use a snippet to check if the lib has been loaded, if not add a script tag to the body, or load it through js, etc...