diff --git a/lib/livebook_web/components/layout_components.ex b/lib/livebook_web/components/layout_components.ex
index 66ae33e35..1013d97b7 100644
--- a/lib/livebook_web/components/layout_components.ex
+++ b/lib/livebook_web/components/layout_components.ex
@@ -312,4 +312,55 @@ defmodule LivebookWeb.LayoutComponents do
defp topbar_class(:warning), do: "bg-yellow-200 text-gray-900"
defp topbar_class(:info), do: "bg-blue-200 text-gray-900"
defp topbar_class(:error), do: "bg-red-200 text-gray-900"
+
+ @doc """
+ Returns an inline script to inject in dev mode.
+
+ The main JS file is loaded asynchronously as a module, so we inline
+ the live reloader listener to make sure it is already registered
+ when the event is dispatched.
+ """
+ if Mix.env() == :dev do
+ def dev_script(assigns) do
+ ~H"""
+
+ """
+ end
+ else
+ def dev_script(assigns), do: ~H""
+ end
end
diff --git a/lib/livebook_web/components/layouts/root.html.heex b/lib/livebook_web/components/layouts/root.html.heex
index 2c27fe7f2..e5adf0c39 100644
--- a/lib/livebook_web/components/layouts/root.html.heex
+++ b/lib/livebook_web/components/layouts/root.html.heex
@@ -14,46 +14,7 @@
-
-
+
<%!-- This prevents the script to be loaded twice in Chrome --%>