Skip to content

Commit fc488c8

Browse files
authored
Merge pull request #29 from bavarianbytes/master
use 'rel=modulepreload' for .mjs files (EcmaScript modules)
2 parents a928762 + 7ccad68 commit fc488c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Classes/Http/ResourcePusher.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4949

5050
protected function addPreloadHeaderToResponse(ResponseInterface $response, string $uri, string $type): ResponseInterface
5151
{
52-
return $response->withAddedHeader('Link', '<' . htmlspecialchars(PathUtility::getAbsoluteWebPath($uri)) . '>; rel=preload; as=' . $type);
52+
if(str_contains($uri, '.mjs')) {
53+
return $response->withAddedHeader('Link', '<' . htmlspecialchars(PathUtility::getAbsoluteWebPath($uri)) . '>; rel=modulepreload; as=' . $type);
54+
} else {
55+
return $response->withAddedHeader('Link', '<' . htmlspecialchars(PathUtility::getAbsoluteWebPath($uri)) . '>; rel=preload; as=' . $type);
56+
}
5357
}
5458
}

0 commit comments

Comments
 (0)