Skip to content

Commit 54ded05

Browse files
committed
[Fizz][Float] stop preloading stylesheets that are not stylesheet resources (#26873)
We previously preloaded stylesheets that were rendered in Fizz. The idea was we'd get a headstart fetching these resources since we know they are going to be rendered. However to really be effective non-float stylesheets need to rendered in the head and the preload here is not helpful and potentially hurtful to perf in a minor way. This change removes this functionality to make the code smaller and simpler DiffTrain build for [5fb2c15](5fb2c15)
1 parent ee61e4a commit 54ded05

File tree

7 files changed

+798
-872
lines changed

7 files changed

+798
-872
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
042d8f606ce643d2eca955badbf07ea5b8ac266c
1+
5fb2c15a89de844a1dd12a61e7674e55dc0dfa89

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-77da47da";
22+
var ReactVersion = "18.3.0-www-classic-f953f2d4";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -4067,31 +4067,13 @@ function pushLink(
40674067
}
40684068
}
40694069

4070-
var resource = resources.preloadsMap.get(key);
4071-
4072-
if (!resource) {
4073-
resource = {
4074-
type: "preload",
4075-
chunks: [],
4076-
state: NoState,
4077-
props: preloadAsStylePropsFromProps(href, props)
4078-
};
4079-
resources.preloadsMap.set(key, resource);
4080-
4081-
{
4082-
markAsImplicitResourceDEV(resource, props, resource.props);
4083-
}
4084-
}
4085-
4086-
pushLinkImpl(resource.chunks, resource.props);
4087-
resources.usedStylesheets.set(key, resource);
40884070
return pushLinkImpl(target, props);
40894071
} else {
40904072
// This stylesheet refers to a Resource and we create a new one if necessary
4091-
var _resource = resources.stylesMap.get(key);
4073+
var resource = resources.stylesMap.get(key);
40924074

40934075
{
4094-
var devResource = getAsResourceDEV(_resource);
4076+
var devResource = getAsResourceDEV(resource);
40954077

40964078
if (devResource) {
40974079
switch (devResource.__provenance) {
@@ -4146,7 +4128,7 @@ function pushLink(
41464128
}
41474129
}
41484130

4149-
if (!_resource) {
4131+
if (!resource) {
41504132
var resourceProps = stylesheetPropsFromRawProps(props);
41514133
var preloadResource = resources.preloadsMap.get(key);
41524134
var state = NoState;
@@ -4165,16 +4147,16 @@ function pushLink(
41654147
}
41664148
}
41674149

4168-
_resource = {
4150+
resource = {
41694151
type: "stylesheet",
41704152
chunks: [],
41714153
state: state,
41724154
props: resourceProps
41734155
};
4174-
resources.stylesMap.set(key, _resource);
4156+
resources.stylesMap.set(key, resource);
41754157

41764158
{
4177-
markAsRenderedResourceDEV(_resource, props);
4159+
markAsRenderedResourceDEV(resource, props);
41784160
}
41794161

41804162
var precedenceSet = resources.precedences.get(precedence);
@@ -4205,11 +4187,11 @@ function pushLink(
42054187
resources.stylePrecedences.set(precedence, emptyStyleResource);
42064188
}
42074189

4208-
precedenceSet.add(_resource);
4190+
precedenceSet.add(resource);
42094191
}
42104192

42114193
if (resources.boundaryResources) {
4212-
resources.boundaryResources.add(_resource);
4194+
resources.boundaryResources.add(resource);
42134195
}
42144196

42154197
if (textEmbedded) {
@@ -4755,10 +4737,10 @@ function pushScript(
47554737
}
47564738
} else {
47574739
// We can make this <script> into a ScriptResource
4758-
var _resource2 = resources.scriptsMap.get(key);
4740+
var _resource = resources.scriptsMap.get(key);
47594741

47604742
{
4761-
var devResource = getAsResourceDEV(_resource2);
4743+
var devResource = getAsResourceDEV(_resource);
47624744

47634745
if (devResource) {
47644746
switch (devResource.__provenance) {
@@ -4812,20 +4794,20 @@ function pushScript(
48124794
}
48134795
}
48144796

4815-
if (!_resource2) {
4816-
_resource2 = {
4797+
if (!_resource) {
4798+
_resource = {
48174799
type: "script",
48184800
chunks: [],
48194801
state: NoState,
48204802
props: null
48214803
};
4822-
resources.scriptsMap.set(key, _resource2);
4804+
resources.scriptsMap.set(key, _resource);
48234805

48244806
{
4825-
markAsRenderedResourceDEV(_resource2, props);
4807+
markAsRenderedResourceDEV(_resource, props);
48264808
} // Add to the script flushing queue
48274809

4828-
resources.scripts.add(_resource2);
4810+
resources.scripts.add(_resource);
48294811
var scriptProps = props;
48304812
var preloadResource = resources.preloadsMap.get(key);
48314813

@@ -4837,7 +4819,7 @@ function pushScript(
48374819
adoptPreloadPropsForScriptProps(scriptProps, preloadResource.props);
48384820
} // encode the tag as Chunks
48394821

4840-
pushScriptImpl(_resource2.chunks, scriptProps);
4822+
pushScriptImpl(_resource.chunks, scriptProps);
48414823
}
48424824
}
48434825

@@ -6298,17 +6280,6 @@ function writePreamble(
62986280
resources.fontPreloads.clear(); // Flush unblocked stylesheets by precedence
62996281

63006282
resources.precedences.forEach(flushAllStylesInPreamble, destination);
6301-
resources.usedStylesheets.forEach(function (resource, key) {
6302-
if (resources.stylesMap.has(key));
6303-
else {
6304-
var _chunks = resource.chunks;
6305-
6306-
for (i = 0; i < _chunks.length; i++) {
6307-
writeChunk(destination, _chunks[i]);
6308-
}
6309-
}
6310-
});
6311-
resources.usedStylesheets.clear();
63126283
resources.scripts.forEach(flushResourceInPreamble, destination);
63136284
resources.scripts.clear();
63146285
resources.usedScripts.forEach(flushResourceInPreamble, destination);
@@ -6376,17 +6347,6 @@ function writeHoistables(destination, resources, responseState) {
63766347
// but we want to kick off preloading as soon as possible
63776348

63786349
resources.precedences.forEach(preloadLateStyles, destination);
6379-
resources.usedStylesheets.forEach(function (resource, key) {
6380-
if (resources.stylesMap.has(key));
6381-
else {
6382-
var chunks = resource.chunks;
6383-
6384-
for (i = 0; i < chunks.length; i++) {
6385-
writeChunk(destination, chunks[i]);
6386-
}
6387-
}
6388-
});
6389-
resources.usedStylesheets.clear();
63906350
resources.scripts.forEach(flushResourceLate, destination);
63916351
resources.scripts.clear();
63926352
resources.usedScripts.forEach(flushResourceLate, destination);
@@ -6878,7 +6838,6 @@ function createResources() {
68786838
// usedImagePreloads: new Set(),
68796839
precedences: new Map(),
68806840
stylePrecedences: new Map(),
6881-
usedStylesheets: new Map(),
68826841
scripts: new Set(),
68836842
usedScripts: new Set(),
68846843
explicitStylesheetPreloads: new Set(),
@@ -7379,10 +7338,10 @@ function preinit(href, options) {
73797338

73807339
var _key = getResourceKey(as, src);
73817340

7382-
var _resource3 = resources.scriptsMap.get(_key);
7341+
var _resource2 = resources.scriptsMap.get(_key);
73837342

73847343
{
7385-
var _devResource = getAsResourceDEV(_resource3);
7344+
var _devResource = getAsResourceDEV(_resource2);
73867345

73877346
if (_devResource) {
73887347
var _propsEquivalent = scriptPropsFromPreinitOptions(src, options);
@@ -7436,29 +7395,29 @@ function preinit(href, options) {
74367395
}
74377396
}
74387397

7439-
if (!_resource3) {
7440-
_resource3 = {
7398+
if (!_resource2) {
7399+
_resource2 = {
74417400
type: "script",
74427401
chunks: [],
74437402
state: NoState,
74447403
props: null
74457404
};
7446-
resources.scriptsMap.set(_key, _resource3);
7405+
resources.scriptsMap.set(_key, _resource2);
74477406

74487407
var _resourceProps = scriptPropsFromPreinitOptions(src, options);
74497408

74507409
{
74517410
markAsImperativeResourceDEV(
7452-
_resource3,
7411+
_resource2,
74537412
"preinit",
74547413
href,
74557414
options,
74567415
_resourceProps
74577416
);
74587417
}
74597418

7460-
resources.scripts.add(_resource3);
7461-
pushScriptImpl(_resource3.chunks, _resourceProps);
7419+
resources.scripts.add(_resource2);
7420+
pushScriptImpl(_resource2.chunks, _resourceProps);
74627421
flushResources(request);
74637422
}
74647423

0 commit comments

Comments
 (0)