Skip to content

Commit df420f6

Browse files
authored
Modernize all index.html files to support WASM (flutter#7114)
Fixes flutter#151663 in preparation for flutter#151664
1 parent 0375259 commit df420f6

File tree

21 files changed

+22
-345
lines changed

21 files changed

+22
-345
lines changed

packages/animations/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<title>example</title>
99
</head>
1010
<body>
11-
<script src="main.dart.js" type="application/javascript"></script>
11+
<script src="flutter_bootstrap.js" async></script>
1212
</body>
1313
</html>

packages/camera/camera/example/web/index.html

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@
2323
</head>
2424

2525
<body>
26-
<!-- This script installs service_worker.js to provide PWA functionality to
27-
application. For more information, see:
28-
https://developers.google.com/web/fundamentals/primers/service-workers -->
29-
<script>
30-
if ('serviceWorker' in navigator) {
31-
window.addEventListener('load', function () {
32-
navigator.serviceWorker.register('flutter_service_worker.js');
33-
});
34-
}
3526
</script>
36-
<script src="main.dart.js" type="application/javascript"></script>
27+
<script src="flutter_bootstrap.js" async></script>
3728
</body>
3829

39-
</html>
30+
</html>

packages/camera/camera_web/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<title>Browser Tests</title>
88
</head>
99
<body>
10-
<script src="main.dart.js"></script>
10+
<script src="flutter_bootstrap.js" async></script>
1111
</body>
1212
</html>

packages/file_selector/file_selector/example/web/index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
<link rel="manifest" href="manifest.json">
2222
</head>
2323
<body>
24-
<!-- This script installs service_worker.js to provide PWA functionality to
25-
application. For more information, see:
26-
https://developers.google.com/web/fundamentals/primers/service-workers -->
27-
<script>
28-
if ('serviceWorker' in navigator) {
29-
window.addEventListener('load', function () {
30-
navigator.serviceWorker.register('flutter_service_worker.js');
31-
});
32-
}
33-
</script>
34-
<script src="main.dart.js" type="application/javascript"></script>
24+
<script src="flutter_bootstrap.js" async></script>
3525
</body>
3626
</html>

packages/file_selector/file_selector_web/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<title>Browser Tests</title>
88
</head>
99
<body>
10-
<script src="main.dart.js"></script>
10+
<script src="flutter_bootstrap.js" async></script>
1111
</body>
1212
</html>

packages/flutter_markdown/example/web/index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@
3333
<link rel="manifest" href="manifest.json">
3434
</head>
3535
<body>
36-
<!-- This script installs service_worker.js to provide PWA functionality to
37-
application. For more information, see:
38-
https://developers.google.com/web/fundamentals/primers/service-workers -->
39-
<script>
40-
if ('serviceWorker' in navigator) {
41-
window.addEventListener('flutter-first-frame', function () {
42-
navigator.serviceWorker.register('flutter_service_worker.js');
43-
});
44-
}
45-
</script>
46-
<script src="main.dart.js" type="application/javascript"></script>
36+
<script src="flutter_bootstrap.js" async></script>
4737
</body>
4838
</html>

packages/go_router/example/web/index.html

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -30,72 +30,6 @@
3030
<link rel="manifest" href="manifest.json">
3131
</head>
3232
<body>
33-
<!-- This script installs service_worker.js to provide PWA functionality to
34-
application. For more information, see:
35-
https://developers.google.com/web/fundamentals/primers/service-workers -->
36-
<script>
37-
var serviceWorkerVersion = null;
38-
var scriptLoaded = false;
39-
function loadMainDartJs() {
40-
if (scriptLoaded) {
41-
return;
42-
}
43-
scriptLoaded = true;
44-
var scriptTag = document.createElement('script');
45-
scriptTag.src = 'main.dart.js';
46-
scriptTag.type = 'application/javascript';
47-
document.body.append(scriptTag);
48-
}
49-
50-
if ('serviceWorker' in navigator) {
51-
// Service workers are supported. Use them.
52-
window.addEventListener('load', function () {
53-
// Wait for registration to finish before dropping the <script> tag.
54-
// Otherwise, the browser will load the script multiple times,
55-
// potentially different versions.
56-
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
57-
navigator.serviceWorker.register(serviceWorkerUrl)
58-
.then((reg) => {
59-
function waitForActivation(serviceWorker) {
60-
serviceWorker.addEventListener('statechange', () => {
61-
if (serviceWorker.state == 'activated') {
62-
console.log('Installed new service worker.');
63-
loadMainDartJs();
64-
}
65-
});
66-
}
67-
if (!reg.active && (reg.installing || reg.waiting)) {
68-
// No active web worker and we have installed or are installing
69-
// one for the first time. Simply wait for it to activate.
70-
waitForActivation(reg.installing ?? reg.waiting);
71-
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
72-
// When the app updates the serviceWorkerVersion changes, so we
73-
// need to ask the service worker to update.
74-
console.log('New service worker available.');
75-
reg.update();
76-
waitForActivation(reg.installing);
77-
} else {
78-
// Existing service worker is still good.
79-
console.log('Loading app from service worker.');
80-
loadMainDartJs();
81-
}
82-
});
83-
84-
// If service worker doesn't succeed in a reasonable amount of time,
85-
// fallback to plaint <script> tag.
86-
setTimeout(() => {
87-
if (!scriptLoaded) {
88-
console.warn(
89-
'Failed to load app from service worker. Falling back to plain <script> tag.',
90-
);
91-
loadMainDartJs();
92-
}
93-
}, 4000);
94-
});
95-
} else {
96-
// Service workers not supported. Just drop the <script> tag.
97-
loadMainDartJs();
98-
}
99-
</script>
33+
<script src="flutter_bootstrap.js" async></script>
10034
</body>
10135
</html>

packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<script src="https://unpkg.com/@googlemaps/[email protected]/dist/index.min.js"></script>
1111
</head>
1212
<body>
13-
<script src="main.dart.js"></script>
13+
<script src="flutter_bootstrap.js" async></script>
1414
</body>
1515
</html>

packages/google_sign_in/google_sign_in_web/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>Browser Tests</title>
88
</head>
99
<body>
10-
<script src="main.dart.js"></script>
10+
<script src="flutter_bootstrap.js" async></script>
1111
</body>
1212
</html>
1313

packages/image_picker/image_picker/example/web/index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
<link rel="manifest" href="manifest.json">
2222
</head>
2323
<body>
24-
<!-- This script installs service_worker.js to provide PWA functionality to
25-
application. For more information, see:
26-
https://developers.google.com/web/fundamentals/primers/service-workers -->
27-
<!-- <script>
28-
if ('serviceWorker' in navigator) {
29-
window.addEventListener('load', function () {
30-
navigator.serviceWorker.register('flutter_service_worker.js');
31-
});
32-
}
33-
</script> -->
34-
<script src="main.dart.js" type="application/javascript"></script>
24+
<script src="flutter_bootstrap.js" async></script>
3525
</body>
3626
</html>

packages/image_picker/image_picker_for_web/example/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<title>example</title>
99
</head>
1010
<body>
11-
<script src="main.dart.js" type="application/javascript"></script>
11+
<script src="flutter_bootstrap.js" async></script>
1212
</body>
1313
</html>

packages/pointer_interceptor/pointer_interceptor/example/web/index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@
3333
<link rel="manifest" href="manifest.json">
3434
</head>
3535
<body>
36-
<!-- This script installs service_worker.js to provide PWA functionality to
37-
application. For more information, see:
38-
https://developers.google.com/web/fundamentals/primers/service-workers -->
39-
<script>
40-
if ('serviceWorker' in navigator) {
41-
window.addEventListener('flutter-first-frame', function () {
42-
navigator.serviceWorker.register('flutter_service_worker.js');
43-
});
44-
}
45-
</script>
46-
<script src="main.dart.js" type="application/javascript"></script>
36+
<script src="flutter_bootstrap.js" async></script>
4737
</body>
4838
</html>

packages/rfw/example/hello/web/index.html

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,72 +36,6 @@
3636
<link rel="manifest" href="manifest.json">
3737
</head>
3838
<body>
39-
<!-- This script installs service_worker.js to provide PWA functionality to
40-
application. For more information, see:
41-
https://developers.google.com/web/fundamentals/primers/service-workers -->
42-
<script>
43-
var serviceWorkerVersion = null;
44-
var scriptLoaded = false;
45-
function loadMainDartJs() {
46-
if (scriptLoaded) {
47-
return;
48-
}
49-
scriptLoaded = true;
50-
var scriptTag = document.createElement('script');
51-
scriptTag.src = 'main.dart.js';
52-
scriptTag.type = 'application/javascript';
53-
document.body.append(scriptTag);
54-
}
55-
56-
if ('serviceWorker' in navigator) {
57-
// Service workers are supported. Use them.
58-
window.addEventListener('load', function () {
59-
// Wait for registration to finish before dropping the <script> tag.
60-
// Otherwise, the browser will load the script multiple times,
61-
// potentially different versions.
62-
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
63-
navigator.serviceWorker.register(serviceWorkerUrl)
64-
.then((reg) => {
65-
function waitForActivation(serviceWorker) {
66-
serviceWorker.addEventListener('statechange', () => {
67-
if (serviceWorker.state == 'activated') {
68-
console.log('Installed new service worker.');
69-
loadMainDartJs();
70-
}
71-
});
72-
}
73-
if (!reg.active && (reg.installing || reg.waiting)) {
74-
// No active web worker and we have installed or are installing
75-
// one for the first time. Simply wait for it to activate.
76-
waitForActivation(reg.installing || reg.waiting);
77-
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
78-
// When the app updates the serviceWorkerVersion changes, so we
79-
// need to ask the service worker to update.
80-
console.log('New service worker available.');
81-
reg.update();
82-
waitForActivation(reg.installing);
83-
} else {
84-
// Existing service worker is still good.
85-
console.log('Loading app from service worker.');
86-
loadMainDartJs();
87-
}
88-
});
89-
90-
// If service worker doesn't succeed in a reasonable amount of time,
91-
// fallback to plaint <script> tag.
92-
setTimeout(() => {
93-
if (!scriptLoaded) {
94-
console.warn(
95-
'Failed to load app from service worker. Falling back to plain <script> tag.',
96-
);
97-
loadMainDartJs();
98-
}
99-
}, 4000);
100-
});
101-
} else {
102-
// Service workers not supported. Just drop the <script> tag.
103-
loadMainDartJs();
104-
}
105-
</script>
39+
<script src="flutter_bootstrap.js" async></script>
10640
</body>
10741
</html>

packages/rfw/example/local/web/index.html

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,72 +36,6 @@
3636
<link rel="manifest" href="manifest.json">
3737
</head>
3838
<body>
39-
<!-- This script installs service_worker.js to provide PWA functionality to
40-
application. For more information, see:
41-
https://developers.google.com/web/fundamentals/primers/service-workers -->
42-
<script>
43-
var serviceWorkerVersion = null;
44-
var scriptLoaded = false;
45-
function loadMainDartJs() {
46-
if (scriptLoaded) {
47-
return;
48-
}
49-
scriptLoaded = true;
50-
var scriptTag = document.createElement('script');
51-
scriptTag.src = 'main.dart.js';
52-
scriptTag.type = 'application/javascript';
53-
document.body.append(scriptTag);
54-
}
55-
56-
if ('serviceWorker' in navigator) {
57-
// Service workers are supported. Use them.
58-
window.addEventListener('load', function () {
59-
// Wait for registration to finish before dropping the <script> tag.
60-
// Otherwise, the browser will load the script multiple times,
61-
// potentially different versions.
62-
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
63-
navigator.serviceWorker.register(serviceWorkerUrl)
64-
.then((reg) => {
65-
function waitForActivation(serviceWorker) {
66-
serviceWorker.addEventListener('statechange', () => {
67-
if (serviceWorker.state == 'activated') {
68-
console.log('Installed new service worker.');
69-
loadMainDartJs();
70-
}
71-
});
72-
}
73-
if (!reg.active && (reg.installing || reg.waiting)) {
74-
// No active web worker and we have installed or are installing
75-
// one for the first time. Simply wait for it to activate.
76-
waitForActivation(reg.installing || reg.waiting);
77-
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
78-
// When the app updates the serviceWorkerVersion changes, so we
79-
// need to ask the service worker to update.
80-
console.log('New service worker available.');
81-
reg.update();
82-
waitForActivation(reg.installing);
83-
} else {
84-
// Existing service worker is still good.
85-
console.log('Loading app from service worker.');
86-
loadMainDartJs();
87-
}
88-
});
89-
90-
// If service worker doesn't succeed in a reasonable amount of time,
91-
// fallback to plaint <script> tag.
92-
setTimeout(() => {
93-
if (!scriptLoaded) {
94-
console.warn(
95-
'Failed to load app from service worker. Falling back to plain <script> tag.',
96-
);
97-
loadMainDartJs();
98-
}
99-
}, 4000);
100-
});
101-
} else {
102-
// Service workers not supported. Just drop the <script> tag.
103-
loadMainDartJs();
104-
}
105-
</script>
39+
<script src="flutter_bootstrap.js" async></script>
10640
</body>
10741
</html>

0 commit comments

Comments
 (0)