-
Notifications
You must be signed in to change notification settings - Fork 10
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
264-fix: load images for smal window #333
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fc82b28
fix: 264 - add svg check
ya6 2105548
fix: 264 - change condition
ya6 3cc7166
fix: 264 - prevent srcset
ya6 09e9152
feat: 264 - add check size utilite
ya6 95c4295
refactor: 264 - del logs
ya6 ecb63a6
fix: 264 - condition parameter
ya6 77d5708
fix: 264 - logical operator
ya6 8320697
refactor: 264 - add constant, make condition for not svg extention
ya6 278a550
refactor: 262 - add synchronous approach for check image size
ya6 b81c5d0
refactor: 262 - add loading img check
ya6 650f57f
refactor: 264 - remove svg files when creating srcSet
ya6 ab14a3c
fix: 264 - remove log
ya6 903417e
refactor: 264 - rename & add return type to function
ya6 00a2312
refactor: 264 - remove default export
ya6 d6453f7
fix: 264 - return different file formats for local development
ya6 c57e298
Merge branch 'main' into fix/264-unknown-error-when-the-browser-windoβ¦
ansivgit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const checkIfSvg = (imgUrl: string): boolean => { | ||
if (imgUrl.endsWith('.svg')) { | ||
return true; | ||
} | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not fix the errors.
From the image optimization doc
There is a clear statement that if an image is already small, the 2 smaller sizes not gonna be created.
Therefore when the browser loading the image that is missing it throws 404 error and Image fallbacks to basic
src
instead ofsrcSet
Because of this behavior, errors occurs.
We have 3 variants on how to fix this:
We can generate two more images with different names but the same size as the original. For example, if the existing logo is named "RS logo" and is 90x90 pixels, we would generate two more copies named "image-name-768" and "image-name-425." These additional images would essentially be placeholders.
This option is more complex. It involves checking all the created images, parsing the build code, and then modifying the srcSet attribute for each image. The modification would be to remove any references to responsive image sizes that are missing.
We can ignore the errors, or somehow clear the console after the image performed fallback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the proposed possible solutions.
If generate a srcSet for them, about 100 more files are added and the size of the application grows
The second option to increase the complexity of an already complex solution will not be optimal
There is another solution to replace the files with svg, but I still donβt think this is the optimal solution.