3 ms·
Have you figured out any good way to have per-page javascript where the JavaScript is only sent over the wire for that pages?
by iudqnolq 6y ago
Have you figured out any good way to have per-page javascript where the JavaScript is only sent over the wire for that pages?
- hnedeotes 6y agoFrom 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...