Skip to content

Commit bb3f5de

Browse files
committed
feat (perf) remove js font loading. css only
1 parent f7382b5 commit bb3f5de

File tree

8 files changed

+10
-71
lines changed

8 files changed

+10
-71
lines changed

header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<!--[if lte IE 9 ]> <html class="no-js ie lte-ie9 ie9" <?php language_attributes( ); ?>> <![endif]-->
33
<!--[if !(IE)]><! -->
4-
<html class="fonts-loading no-js" <?php language_attributes( ); ?>>
4+
<html class="no-js" <?php language_attributes( ); ?>>
55
<!--<![endif]-->
66
<head>
77
<script type="text/javascript">

inc/async/loadfont.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
11
<!-- Polyfill.io -->
22
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=es5,es6,fetch,Array.prototype.includes,CustomEvent,Element.prototype.closest,NodeList.prototype.forEach"></script>
3-
4-
<script>
5-
// inline loadJS
6-
function loadJS(e,t){"use strict";var n=window.document.getElementsByTagName("script")[0],o=window.document.createElement("script");return o.src=e,o.async=!0,n.parentNode.insertBefore(o,n),t&&"function"==typeof t&&(o.onload=t),o}
7-
// then load your JS
8-
if (sessionStorage.getItem('fonts-loaded')) {
9-
// fonts cached, add class to document
10-
document.documentElement.classList.remove('fonts-loading');
11-
} else {
12-
// load script with font observing logic
13-
loadJS('<?php echo get_theme_file_uri( '/src/js/vendor_async/fonts-css-async.js' );?>');
14-
}
15-
</script>

src/js/vendor_async/fonts-css-async.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/scss/abstract/_mixins.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@
279279
line-height: $heading-line-height;
280280
font-family: $customfont-2;
281281

282-
.fonts-loading & {
283-
font-family: $font-sansserif;
284-
}
285-
286282
@if $size == XXL {
287283
font-size: 40px;
288284

src/scss/base/_text.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ body {
3030
-webkit-font-smoothing: antialiased;
3131
-moz-osx-font-smoothing: grayscale;
3232
overflow-x: hidden;
33-
//Fonts loading FOUT
34-
//Adjust FOUT with tools like https://meowni.ca/font-style-matcher/
35-
.fonts-loading & {
36-
font-family: $font-sansserif;
37-
}
3833
}
3934

4035
a {

src/scss/wp/_wysiwyg.scss

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
.wysiwyg {
22
@include clearfix;
33

4-
// * {
5-
// margin-bottom: $base-spacing;
4+
>* {
5+
margin-bottom: $base-spacing;
66

7-
// &:last-child {
8-
// margin-bottom: 0;
9-
// }
10-
// }
7+
&:last-child {
8+
margin-bottom: 0;
9+
}
10+
}
1111

12-
a:not([class]) {
12+
>a:not([class]) {
1313
text-decoration: underline;
1414

1515
@include hover {
@@ -27,6 +27,7 @@
2727

2828
img {
2929
@include img__responsive;
30+
3031
&.alignright,
3132
&.alignleft {
3233
max-width: 50%;

src/templates/partials/footer.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,6 @@
2929
<!-- Polyfill.io -->
3030
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=es5,es6,fetch,Array.prototype.includes,CustomEvent,Element.prototype.closest,NodeList.prototype.forEach"></script>
3131

32-
33-
<script>
34-
// inline loadJS
35-
function loadJS(e,t){"use strict";var n=window.document.getElementsByTagName("script")[0],o=window.document.createElement("script");return o.src=e,o.async=!0,n.parentNode.insertBefore(o,n),t&&"function"==typeof t&&(o.onload=t),o}
36-
37-
// then load your JS
38-
if (sessionStorage.getItem('fonts-loaded')) {
39-
// fonts cached, add class to document
40-
document.documentElement.classList.remove('fonts-loading')
41-
} else {
42-
// load script with font observing logic
43-
loadJS('assets/js/vendor_async/fonts-css-async.js')
44-
}
45-
</script>
46-
4732
<!-- Theme js -->
4833
<?php
4934
if ( is_readable( dirname( __FILE__ ) . '/../WebpackBuiltFiles.php' ) ) {

src/templates/partials/header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!doctype html>
33
<!--[if lte IE 9 ]> <html class="no-js ie lte-ie9 ie9" lang="fr"> <![endif]-->
44
<!--[if !(IE)]><! -->
5-
<html class="fonts-loading no-js" lang="fr"><!--<![endif]-->
5+
<html class="no-js" lang="fr"><!--<![endif]-->
66
<head>
77

88
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

0 commit comments

Comments
 (0)