Skip to content

Render-blocking dark-theme initialization for dartdoc pages. #8837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/lib/dartdoc/dartdoc_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ extension DartDocPageRender on DartDocPage {
'width': '0',
'style': 'display:none;visibility:hidden',
})),
// NOTE: dartdoc's own initialization will still run, but it is not in conflict
// with the current script.
d.script(src: staticUrls.getAssetUrl('/static/js/dark-init.js')),
d.div(id: 'overlay-under-drawer'),
_renderHeader(options),
_renderMain(options),
Expand Down
8 changes: 8 additions & 0 deletions app/test/dartdoc/dartdoc_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ void main() {
contains('https://www.googletagmanager.com/'));
firstNoScript.remove();

// removing extra dark-theme initializer script
renderedXmlDoc.descendantElements
.where((e) =>
e.localName == 'script' &&
e.getAttribute('src')!.endsWith('/dark-init.js'))
.single
.remove();

// removing extra logo
final firstLogo = renderedXmlDoc.descendantElements.firstWhere(
(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down