Answer the question
In order to leave comments, you need to log in
How to reduce font size?
The main part of the website is the constructor, in which the user himself creates the design of the bathrobe. He writes an inscription, then chooses a font for it. There are 6 different fonts to choose from, which are not available in Windows and macOS by default. Google Fonts does not have them either, so they just lie in the fonts folder and are loaded along with the site loading. Because of this, the site loads in about 30 seconds, and the font folder itself weighs several times more than the rest of the site, including images. How can this be fixed? The choice of the font of the inscription in any way should remain, since this is the main function of the site.
Answer the question
In order to leave comments, you need to log in
Make dynamic data loading. The user selected a font -> loaded it via ajax.
Something like this ->
const url = 'https://fonts.googleapis.com/css?family=Oswald'
const button = document.querySelector('button')
button.addEventListener('click', event => {
fetch(url)
.then(response => response.text())
.then(font => {
const style = document.createElement('style')
style.innerHTML = font
document.head.appendChild(style)
})
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question