Skip to content

Commit

Permalink
Use IE conditional comment placeholders for server island start marke…
Browse files Browse the repository at this point in the history
…rs (#12090)

These placeholders are much less likely to be removed by HTML minifiers,
because they have traditionally been used to change the behavior of
site.
  • Loading branch information
markjaquith authored Oct 1, 2024
1 parent 11d447f commit d49a537
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-apes-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers.
4 changes: 2 additions & 2 deletions packages/astro/src/runtime/server/render/server-islands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function renderServerIsland(
}
}

destination.write('<!--server-island-start-->');
destination.write('<!--[if astro]>server-island-start<![endif]-->');

// Render the slots
const renderedSlots: Record<string, string> = {};
Expand Down Expand Up @@ -88,7 +88,7 @@ if(response.status === 200 && response.headers.get('content-type') === 'text/htm
// Swap!
while(script.previousSibling &&
script.previousSibling.nodeType !== 8 &&
script.previousSibling.data !== 'server-island-start') {
script.previousSibling.data !== '[if astro]>server-island-start<![endif]') {
script.previousSibling.remove();
}
script.previousSibling?.remove();
Expand Down

0 comments on commit d49a537

Please sign in to comment.