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

Issue 514893002: Lower priority of async scripts (Closed)

Created:
6 years, 3 months ago by Pat Meenan
Modified:
6 years, 3 months ago
Reviewers:
tonyg, eseidel
CC:
blink-reviews, blink-reviews-dom_chromium.org, blink-reviews-html_chromium.org, dglazkov+blink, eae+blinkwatch, gavinp+loader_chromium.org, Nate Chapin, rwlbuis, sof
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Lower priority of async scripts All scripts currently load at a medium priority and compete with each other for resources. Async scripts do not block the parser and should be loaded at a lower priority than those that do. This patch lowers the priority of scripts with async or defer attributes and scripts that were injected dynamically to load at a "low" priority which is below blocking scripts but above (non-visible) images. Visible images are loaded at the same priority but with a higher intra-priority based on the screen area they cover so visible images can preempt async scripts once layout is done (a good thing). We want to keep scripts at a higher priority than (non-visible) images for a couple of reasons: 1 - Scripts may cause other resource loads while images do not (generally). There is potential to push out the onload time of the page if a script with lots of follow-on content is loaded at the end after images. 2 - By the time the code executes to inject the script the preload parser may have already discovered the bulk of the images on the page. Test results: https://docs.google.com/spreadsheet/ccc?key=0As3TLupYw2RedC1RUHlMRHhFY3RoVHEtc2FhbXQ1aWc&usp=sharing Slight improvements (~1%) to onload, render and DOM Content Loaded. 1-2% improvement on Speed Index. BUG=408229 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=181842

Patch Set 1 : Moved async script priority to low #

Total comments: 6

Patch Set 2 : Fixed the usage of "const bool" #

Patch Set 3 : Fixed member initialization order #

Patch Set 4 : Switched to use DeferOption to track state #

Patch Set 5 : Cleaned up a few stray member variables #

Unified diffs Side-by-side diffs Delta from patch set Stats (+97 lines, -5 lines) Patch
A LayoutTests/http/tests/loading/resources/body.js View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/resources/document-write.js View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/resources/head.js View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/resources/injected.js View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/resources/injected-async.js View 1 chunk +1 line, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/script-priorities.html View 1 chunk +31 lines, -0 lines 0 comments Download
A LayoutTests/http/tests/loading/script-priorities-expected.txt View 1 chunk +24 lines, -0 lines 0 comments Download
M Source/core/dom/ScriptLoader.h View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M Source/core/dom/ScriptLoader.cpp View 1 2 3 3 chunks +6 lines, -2 lines 0 comments Download
M Source/core/fetch/FetchRequest.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M Source/core/fetch/ResourceFetcher.cpp View 1 2 3 1 chunk +6 lines, -1 line 0 comments Download
M Source/core/html/parser/HTMLPreloadScanner.cpp View 1 2 3 5 chunks +17 lines, -0 lines 0 comments Download
M Source/core/html/parser/HTMLResourcePreloader.h View 1 2 3 3 chunks +4 lines, -0 lines 0 comments Download
M Source/core/html/parser/HTMLResourcePreloader.cpp View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 12 (2 generated)
Pat Meenan
Patchset #1 (id:1) has been deleted
6 years, 3 months ago (2014-08-27 19:08:25 UTC) #1
Pat Meenan
Here is the first patch from breaking up https://codereview.chromium.org/457413002/ Not much gains but it's probably ...
6 years, 3 months ago (2014-09-03 14:40:44 UTC) #3
eseidel
I'm fine with the concept. I'm sad at the metric ton of plumbing required to ...
6 years, 3 months ago (2014-09-03 15:15:39 UTC) #4
eseidel
Could you speak more to the corpus against which you're optimizing? Is it mobile? Ideally ...
6 years, 3 months ago (2014-09-03 15:18:10 UTC) #5
Pat Meenan
On 2014/09/03 15:18:10, eseidel wrote: > Could you speak more to the corpus against which ...
6 years, 3 months ago (2014-09-03 16:16:02 UTC) #6
Pat Meenan
https://codereview.chromium.org/514893002/diff/20001/Source/core/dom/ScriptLoader.cpp File Source/core/dom/ScriptLoader.cpp (right): https://codereview.chromium.org/514893002/diff/20001/Source/core/dom/ScriptLoader.cpp#newcode104 Source/core/dom/ScriptLoader.cpp:104: m_forceAsync = false; On 2014/09/03 15:18:10, eseidel wrote: > ...
6 years, 3 months ago (2014-09-03 16:16:17 UTC) #7
Pat Meenan
I switched everything over to use DeferOption and added a "LazyLoad" state for the option ...
6 years, 3 months ago (2014-09-11 18:18:59 UTC) #8
eseidel
lgtm
6 years, 3 months ago (2014-09-11 18:20:52 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patchset/514893002/90001
6 years, 3 months ago (2014-09-11 18:26:45 UTC) #11
commit-bot: I haz the power
6 years, 3 months ago (2014-09-11 19:41:07 UTC) #12
Message was sent while issue was closed.
Committed patchset #5 (id:90001) as 181842

Powered by Google App Engine
This is Rietveld 408576698