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

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 457413002: Defer late and async scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Lower priorities for late/async scripts 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 unified diff | Download patch
« no previous file with comments | « Source/core/fetch/FetchRequest.cpp ('k') | Source/core/fetch/ResourceLoadPriorityOptimizer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 static ResourceLoadPriority loadPriority(Resource::Type type, const FetchRequest & request) 114 static ResourceLoadPriority loadPriority(Resource::Type type, const FetchRequest & request)
115 { 115 {
116 if (request.priority() != ResourceLoadPriorityUnresolved) 116 if (request.priority() != ResourceLoadPriorityUnresolved)
117 return request.priority(); 117 return request.priority();
118 118
119 switch (type) { 119 switch (type) {
120 case Resource::MainResource: 120 case Resource::MainResource:
121 return ResourceLoadPriorityVeryHigh; 121 return ResourceLoadPriorityVeryHigh;
122 case Resource::CSSStyleSheet:
123 return ResourceLoadPriorityHigh;
124 case Resource::Raw: 122 case Resource::Raw:
125 return request.options().synchronousPolicy == RequestSynchronously ? Res ourceLoadPriorityVeryHigh : ResourceLoadPriorityMedium; 123 return request.options().synchronousPolicy == RequestSynchronously ? Res ourceLoadPriorityVeryHigh : ResourceLoadPriorityMedium;
124 case Resource::CSSStyleSheet:
126 case Resource::Script: 125 case Resource::Script:
126 // CSS and Script get the same treatment and priority levels so we load them in order
127 // and they can block each other's parsing/execution (with the exception of async scripts).
128 // Async scripts do not block the parser so they get the lowest priority and can be
129 // loaded in parser order with images.
130 if (type == Resource::Script && request.execAsync())
131 return ResourceLoadPriorityVeryLow;
132 // Scripts or CSS discovered by the preload scanner that are not in the head get a low priority
133 // so they do not load while we are loading the layout-blocking resource s but still load
134 // at a higher priority than images since they block the main parser.
135 if (request.forPreload() && !request.isBeforeBody())
136 return ResourceLoadPriorityLow;
137 return ResourceLoadPriorityMedium;
127 case Resource::Font: 138 case Resource::Font:
128 case Resource::ImportResource: 139 case Resource::ImportResource:
129 return ResourceLoadPriorityMedium; 140 return ResourceLoadPriorityMedium;
130 case Resource::Image: 141 case Resource::Image:
131 // We'll default images to VeryLow, and promote whatever is visible. Thi s improves 142 // We'll default images to VeryLow, and promote whatever is visible. Thi s improves
132 // speed-index by ~5% on average, ~14% at the 99th percentile. 143 // speed-index by ~5% on average, ~14% at the 99th percentile.
133 return ResourceLoadPriorityVeryLow; 144 return ResourceLoadPriorityVeryLow;
134 case Resource::Media: 145 case Resource::Media:
135 return ResourceLoadPriorityLow; 146 return ResourceLoadPriorityLow;
136 case Resource::XSLStyleSheet: 147 case Resource::XSLStyleSheet:
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 1551
1541 void ResourceFetcher::trace(Visitor* visitor) 1552 void ResourceFetcher::trace(Visitor* visitor)
1542 { 1553 {
1543 visitor->trace(m_document); 1554 visitor->trace(m_document);
1544 visitor->trace(m_loaders); 1555 visitor->trace(m_loaders);
1545 visitor->trace(m_multipartLoaders); 1556 visitor->trace(m_multipartLoaders);
1546 ResourceLoaderHost::trace(visitor); 1557 ResourceLoaderHost::trace(visitor);
1547 } 1558 }
1548 1559
1549 } 1560 }
OLDNEW
« no previous file with comments | « Source/core/fetch/FetchRequest.cpp ('k') | Source/core/fetch/ResourceLoadPriorityOptimizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698