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

Commit 6488501

Browse files
committed
move %sapper.scripts% to <head> with defer
1 parent 31d6f05 commit 6488501

File tree

21 files changed

+24
-25
lines changed

21 files changed

+24
-25
lines changed

runtime/src/server/middleware/get_page_handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export function get_page_handler(
289289
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)`;
290290
}
291291
} else {
292-
script += `</script><script src="${main}">`;
292+
script += `</script><script src="${main}" defer>`;
293293
}
294294

295295
let styles: string;

site/src/template.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
<!-- This contains the contents of the <svelte:head> component, if
3939
the current page has one -->
4040
%sapper.head%
41+
<!-- Sapper creates a <script> tag containing `app/client.js`
42+
and anything else it needs to hydrate the app and
43+
initialise the router -->
44+
%sapper.scripts%
4145
</head>
4246
<body>
4347
<!-- The application will be rendered inside this element,
4448
because `app/client.js` references it -->
4549
<div id='sapper'>%sapper.html%</div>
46-
47-
<!-- Sapper creates a <script> tag containing `app/client.js`
48-
and anything else it needs to hydrate the app and
49-
initialise the router -->
50-
%sapper.scripts%
5150
</body>
5251
</html>

test/apps/basics/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/credentials/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/css/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/custom-extension/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/encoding/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/errors/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/export-multiple-entry/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/export-queue/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/export-webpack/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/export/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/ignore/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/layout/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/preloading/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/redirects/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/scroll/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/session/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/with-basepath/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/with-sourcemaps-webpack/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

test/apps/with-sourcemaps/src/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
%sapper.base%
77
%sapper.styles%
88
%sapper.head%
9+
%sapper.scripts%
910
</head>
1011
<body>
1112
<div id='sapper'>%sapper.html%</div>
12-
%sapper.scripts%
1313
</body>
1414
</html>

0 commit comments

Comments
 (0)