Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

move %sapper.scripts% to <head> with defer #1123

Merged
merged 1 commit into from
Jul 31, 2020
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
2 changes: 1 addition & 1 deletion runtime/src/server/middleware/get_page_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export function get_page_handler(
script += `var s=document.createElement("script");try{new Function("if(0)import('')")();s.src="${main}";s.type="module";s.crossOrigin="use-credentials";}catch(e){s.src="${req.baseUrl}/client/shimport@${build_info.shimport}.js";s.setAttribute("data-main","${main}")}document.head.appendChild(s)`;
}
} else {
script += `</script><script src="${main}">`;
script += `</script><script src="${main}" defer>`;
}

let styles: string;
Expand Down
9 changes: 4 additions & 5 deletions site/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@
<!-- This contains the contents of the <svelte:head> component, if
the current page has one -->
%sapper.head%
<!-- Sapper creates a <script> tag containing `app/client.js`
and anything else it needs to hydrate the app and
initialise the router -->
%sapper.scripts%
</head>
<body>
<!-- The application will be rendered inside this element,
because `app/client.js` references it -->
<div id='sapper'>%sapper.html%</div>

<!-- Sapper creates a <script> tag containing `app/client.js`
and anything else it needs to hydrate the app and
initialise the router -->
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/basics/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/credentials/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/css/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/custom-extension/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/encoding/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/errors/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/export-multiple-entry/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/export-queue/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/export-webpack/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/export/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/ignore/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/layout/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/preloading/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/redirects/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/scroll/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/session/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/with-basepath/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/with-sourcemaps-webpack/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>
2 changes: 1 addition & 1 deletion test/apps/with-sourcemaps/src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
%sapper.base%
%sapper.styles%
%sapper.head%
%sapper.scripts%
</head>
<body>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
</body>
</html>