Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(768)

Unified Diff: Source/core/dom/ScriptLoader.cpp

Issue 514893002: Lower priority of async scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleaned up a few stray member variables Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/fetch/FetchRequest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptLoader.cpp
diff --git a/Source/core/dom/ScriptLoader.cpp b/Source/core/dom/ScriptLoader.cpp
index 6483ef8c84114c342d6ef3b13ff1fdf867870704..694873aec75e9659d72d9c9cdd17ffaca8fa3231 100644
--- a/Source/core/dom/ScriptLoader.cpp
+++ b/Source/core/dom/ScriptLoader.cpp
@@ -217,7 +217,10 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
m_characterEncoding = elementDocument.charset();
if (client->hasSourceAttribute()) {
- if (!fetchScript(client->sourceAttributeValue()))
+ FetchRequest::DeferOption defer = FetchRequest::NoDefer;
+ if (!m_parserInserted || client->asyncAttributeValue() || client->deferAttributeValue())
+ defer = FetchRequest::LazyLoad;
+ if (!fetchScript(client->sourceAttributeValue(), defer))
return false;
}
@@ -246,7 +249,7 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
return true;
}
-bool ScriptLoader::fetchScript(const String& sourceUrl)
+bool ScriptLoader::fetchScript(const String& sourceUrl, FetchRequest::DeferOption defer)
{
ASSERT(m_element);
@@ -266,6 +269,7 @@ bool ScriptLoader::fetchScript(const String& sourceUrl)
bool scriptPassesCSP = elementDocument->contentSecurityPolicy()->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr));
if (scriptPassesCSP)
request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy);
+ request.setDefer(defer);
m_resource = elementDocument->fetcher()->fetchScript(request);
m_isExternalScript = true;
« no previous file with comments | « Source/core/dom/ScriptLoader.h ('k') | Source/core/fetch/FetchRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698