diff --git a/engine/core/html/parser/HTMLDocumentParser.cpp b/engine/core/html/parser/HTMLDocumentParser.cpp
index ae830ca6ead..eaf579302c4 100644
--- a/engine/core/html/parser/HTMLDocumentParser.cpp
+++ b/engine/core/html/parser/HTMLDocumentParser.cpp
@@ -388,6 +388,8 @@ void HTMLDocumentParser::resumeAfterWaitingForImports()
m_scriptRunner.executePendingScripts();
ASSERT(!isExecutingScript());
ASSERT(!isWaitingForScripts());
+ if (m_speculations.isEmpty())
+ return;
ASSERT(m_haveBackgroundParser);
pumpPendingSpeculations();
}