Skip to content

Commit ccdf71c

Browse files
authored
Merge pull request #891 from haxtheweb/perf/static-build-cdn
[haxcms-php] Static shell: mark the build/ check for site:build-static (#3429)
2 parents 5784a26 + c1282da commit ccdf71c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎system/backend/php/tests/Unit/BoilerplateShellPreloadsTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,15 @@ public function testRenderedPageHiddenWhileLoadingAndShownWithoutJs(): void
6969
$this->assertStringContainsString('body:has(> #loading[aria-busy="true"]) haxcms-site-builder {', $html);
7070
$this->assertMatchesRegularExpression('/<noscript>[\s\S]*#loading \{\s*display: none !important;[\s\S]*visibility: visible !important;[\s\S]*<\/noscript>/', $html);
7171
}
72+
73+
// haxtheweb/issues#3429: site:build-static replaces the marked check
74+
// with the place it knows build/ comes from
75+
public function testBuildCheckIsMarkedForStaticBuilds(): void
76+
{
77+
$html = $this->shell();
78+
$this->assertSame(1, substr_count($html, '<script data-haxcms-cdn-check>'));
79+
$check = strpos($html, '<script data-haxcms-cdn-check>');
80+
$this->assertGreaterThan($check, strpos($html, "xhr.open('HEAD'"));
81+
$this->assertGreaterThan($check, strpos($html, 'importmap.type = "importmap"'));
82+
}
7283
}

‎system/boilerplate/site/ghpages.html‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
seoTag.setAttribute('content', document.location.href);
3030
}
3131
</script>
32-
<script>
32+
<script data-haxcms-cdn-check>
33+
// decides where build/ comes from; site:build-static replaces this with
34+
// its own answer when it knows it (haxtheweb/issues#3429)
3335
(function() {
3436
var cdn = "./";
3537
try {

0 commit comments

Comments
 (0)