Skip to content

Commit 2fe20ce

Browse files
author
“bc-yevhenii-buliuk”
committed
fix(storefront): BCTHEME-991 Cornerstone performance optimizations: blocking scripts delaying DomContentLoaded.
1 parent 0e132e8 commit 2fe20ce

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## Draft
8+
- Cornerstone performance optimizations: blocking scripts delaying DomContentLoaded. [#2158](https://github.com/bigcommerce/cornerstone/pull/2158)
89

910
## 6.2.0 (12-13-2021)
1011
- Fix tooltip on close button of modal is shifted. [#2148](https://github.com/bigcommerce/cornerstone/pull/2148)

assets/js/theme/common/font.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const WebFont = require('webfontloader');
2+
3+
WebFont.load({
4+
custom: {
5+
families: ['Karla', 'Roboto', 'Source Sans Pro', 'Volkhov', 'Montserrat', 'Open Sans']
6+
},
7+
classes: false
8+
});

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"slick-carousel": "^1.8.1",
2626
"svg-injector": "^1.1.3",
2727
"sweetalert2": "^9.17.2",
28+
"webfontloader": "^1.6.28",
2829
"whatwg-fetch": "^3.6.1"
2930
},
3031
"devDependencies": {

templates/layout/base.html

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@
2626
</script>
2727
<script async src="{{cdn 'assets/dist/theme-bundle.head_async.js'}}"></script>
2828

29-
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
30-
31-
<script>
32-
WebFont.load({
33-
custom: {
34-
families: ['Karla', 'Roboto', 'Source Sans Pro']
35-
},
36-
classes: false
37-
});
38-
</script>
29+
<script src="{{cdn 'assets/dist/theme-bundle.font.js'}}"></script>
3930

4031
{{ getFontsCollection }}
4132
{{{stylesheet '/assets/css/theme.css'}}}
@@ -67,11 +58,13 @@
6758
{{> components/common/footer }}
6859

6960
<script>window.__webpack_public_path__ = "{{cdn 'assets/dist/'}}";</script>
70-
<script src="{{cdn 'assets/dist/theme-bundle.main.js'}}"></script>
7161
<script>
7262
{{!-- Exported in app.js --}}
73-
window.stencilBootstrap("{{page_type}}", {{jsContext}}).load();
63+
function onThemeBundleMain() {
64+
window.stencilBootstrap("{{page_type}}", {{jsContext}}).load();
65+
}
7466
</script>
67+
<script defer src="{{cdn 'assets/dist/theme-bundle.main.js'}}" onload="onThemeBundleMain()"></script>
7568

7669
{{{footer.scripts}}}
7770
</body>

webpack.common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
entry: {
1212
main: './assets/js/app.js',
1313
head_async: ['lazysizes'],
14+
font: './assets/js/theme/common/font.js',
1415
polyfills: './assets/js/polyfills.js',
1516
},
1617
module: {

0 commit comments

Comments
 (0)