diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
index 84d3736220..e2aa2a78c8 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
@@ -31,7 +31,7 @@ void HTMLScriptElement::set_parser_document(Badge, DOM::Document& do
m_parser_document = document;
}
-void HTMLScriptElement::begin_delaying_document_load_event(Badge, DOM::Document& document)
+void HTMLScriptElement::begin_delaying_document_load_event(DOM::Document& document)
{
// https://html.spec.whatwg.org/multipage/scripting.html#concept-script-script
// The user agent must delay the load event of the element's node document until the script is ready.
@@ -295,6 +295,9 @@ void HTMLScriptElement::prepare_script()
// Fetch a classic script given url, settings object, options, classic script CORS setting, and encoding.
auto request = LoadRequest::create_for_url_on_page(url, document().page());
+ if (parser_document)
+ begin_delaying_document_load_event(*parser_document);
+
ResourceLoader::the().load(
request,
[this, url](auto data, auto&, auto) {
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
index a104e41ece..589773eae5 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h
@@ -42,12 +42,11 @@ public:
void set_source_line_number(Badge, size_t source_line_number) { m_source_line_number = source_line_number; }
- void begin_delaying_document_load_event(Badge, DOM::Document&);
-
private:
void prepare_script();
void script_became_ready();
void when_the_script_is_ready(Function);
+ void begin_delaying_document_load_event(DOM::Document&);
WeakPtr m_parser_document;
WeakPtr m_preparation_time_document;
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index a2b41c4540..203fcf2456 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -2094,10 +2094,6 @@ void HTMLParser::handle_text(HTMLToken& token)
NonnullRefPtr script = verify_cast(current_node());
- // The document's "load" event is delayed until every script becomes ready.
- // See HTMLScriptElement internals for how readiness is determined.
- script->begin_delaying_document_load_event({}, *m_document);
-
(void)m_stack_of_open_elements.pop();
m_insertion_mode = m_original_insertion_mode;
// Let the old insertion point have the same value as the current insertion point.