Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix font preloads on multilang sites #1018

Merged
merged 1 commit into from
Dec 13, 2021
Merged

Conversation

cea2aj
Copy link
Member

@cea2aj cea2aj commented Dec 10, 2021

Fix font preloads on multilang sites and no longer generate a hash for fonts

When webpack was processing the preload tags to update them to use the hash, it was dropping the relative path which jambo was adding which caused the preloads to point to invalid links on multilang sites. I couldn't find an option to adjust the path names after webpack processed it, so the simpler solution is to remove the hashes from the fonts. That way webpack will no longer need to update the font preloads and we can instead rely on the relative path provided by Jambo.

There was an additional bug where we had an extra dot in the font names. (e.g. source-sans..woff), and this change fixes that as well.

Because we are removing the hash, that makes it more difficult to cache bust it. If someone uses a new font file and names it exactly the same as one of the previous fonts, they cache will return the old asset. The current font names are so specific that I find this unlikely to be a problem (e.g. source-sans-pro-v14-latin-300.woff).

J=SLAP-1724
TEST=manual

Check the network tab for font loads on english experiences and on multilang pages. Check both universal and vertical pages and observe that the error in the console about invalid font preloads is gone for multilang sites. See that the loaded font no longer has an extra dot before the extension.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 8.856% when pulling 7e1450e on dev/fix-multilang-font-preloads into 4ff3f0d on develop.

}
}
]
},
{
test: /\.(png|ico|gif|jpe?g|svg|webp|eot|otf|ttf|woff2?)$/,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oshi97 Can you confirm this is only impacting fonts based on this comment?: #889 (comment)

Copy link
Member Author

@cea2aj cea2aj Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to confirm whether or not removing the hash will have impacts on the other files types listed in the test. I'm not seeing hashes on any other types of assets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fine

<link rel="preload" as="font" href="{{relativePath}}/static/assets/fonts/source-sans-pro-v14-latin-600.woff" type="font/woff" crossorigin="anonymous">
<link rel="preload" as="font" href="{{relativePath}}/static/assets/fonts/source-sans-pro-v14-latin-700.woff" type="font/woff" crossorigin="anonymous">
<link rel="preload" as="font" href="{{relativePath}}/static/assets/fonts/source-sans-pro-v14-latin-regular.woff" type="font/woff" crossorigin="anonymous">
<link rel="preload" as="font" href="{{relativePath}}/source-sans-pro-v14-latin-300.woff" type="font/woff" crossorigin="anonymous">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right url for the fonts? I thought resolve-url-loader would still add hashes to the font used by the css

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I took a look at the resolve-url-loader docs and I don't see anything related to hashes. Its primary job is to update paths. I also checked the network tab and there are no longer any errors for font preloading

Copy link
Contributor

@oshi97 oshi97 Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah all resolve-url-loader does is add the css as additional webpack imports

{
test: /\.(png|ico|gif|jpe?g|svg|webp|eot|otf|ttf|woff2?)$/,
type: 'asset/resource',
generator: {
filename: '[name].[hash].[ext]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 no more extra period lol

Copy link
Contributor

@oshi97 oshi97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@cea2aj cea2aj merged commit 2f8e363 into develop Dec 13, 2021
@cea2aj cea2aj deleted the dev/fix-multilang-font-preloads branch December 13, 2021 16:59
@tmeyer2115 tmeyer2115 mentioned this pull request Dec 14, 2021
tmeyer2115 added a commit that referenced this pull request Dec 14, 2021
### Features
- Consumer Authentication support was added for the Sandbox environment. (#996)
- The existing `image` formatter was updated to support photos sent from the Streams API. (#998)
- Support for Direct Answers on Vertical was added to the `vertical-standard` template. It is commented out by default. (#994)

### Changes
- To better support Consumer Authentication, the `AnswersExperience.init()` method can be called on `Document` load. (#995)
- The default `universalLimit` for all Vertical page configs was updated to 4. (#1010, #1021)

### Bugfixes
- Ensured that in all page templates, the `SpellCheck` appears above the `ResultsCount`. (#1011, #1017)
- In the `highlightedField` formatter, any HTML tag that appears in the text, that is not `<mark>` or `</mark>`, is now escaped. (#1012)
- Font pre-loads on Multi-lang sites now work correctly. (#1018)
- A new CSS variable was added: `--yxt-filter-options-option-label-line-height`. This variable, when kept in proper proportion to `--yxt-filters-and-sorts-font-size`, will ensure the scroll bar does not erroneously appear for filter options. (#1015, #1019)
@tmeyer2115 tmeyer2115 mentioned this pull request Jan 11, 2022
tmeyer2115 added a commit that referenced this pull request Jan 11, 2022
### Features
- Consumer Authentication support was added for the Sandbox environment. (#996)
- The existing `image` formatter was updated to support photos sent from the Streams API. (#998)
- Support for Direct Answers on Vertical was added to the `vertical-standard` template. It is commented out by default. (#994)

### Changes
- To better support Consumer Authentication, the `AnswersExperience.init()` method can be called on `Document` load. (#995)
- The default `universalLimit` for all Vertical page configs was updated to 4. (#1010, #1021)

### Bugfixes
- Ensured that in all page templates, the `SpellCheck` appears above the `ResultsCount`. (#1011, #1017)
- In the `highlightedField` formatter, any HTML tag that appears in the text, that is not `<mark>` or `</mark>`, is now escaped. (#1012)
- Font pre-loads on Multi-lang sites now work correctly. (#1018)
- A new CSS variable was added: `--yxt-filter-options-option-label-line-height`. This variable, when kept in proper proportion to `--yxt-filters-and-sorts-font-size`, will ensure the scroll bar does not erroneously appear for filter options. (#1015, #1019)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants