Skip to content

Commit 81697ce

Browse files
authored
W-17609247 - Fix Safari bug where the same image loads several times (#2223)
* Move src to be below srcSet * Add comments and changelog
1 parent fa067c1 commit 81697ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/template-retail-react-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Allow store to be selectable in StoreLocator [#2187](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2187)
1010
- [BUG] Fixed "getCheckboxProps is not a function" when rendering checkout page in generated app.[#2140](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2140)
1111
- Replace transfer basket call with merge basket on checkout [#2138](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2138)
12+
- [BUG] Fix images being fetced multiple times on Safari [#2223](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2223)
1213

1314
### Accessibility Improvements
1415
- [a11y] Fix LinkList component to follow a11y practise [#2098])(https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2098)

packages/template-retail-react-app/app/utils/responsive-image.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ export const getResponsiveImageAttributes = ({src, widths, breakpoints = default
3838
themeBreakpoints = breakpoints
3939
breakpointLabels = getBreakpointLabels(themeBreakpoints)
4040

41+
// Order of these attributes matter! If src is not last, Safari will refetch images
42+
// multiple times (once when it processes src and again when it processes sizes / srcSet)
43+
// See https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2223
4144
return {
42-
src: getSrcWithoutOptionalParams(src),
4345
sizes: mapWidthsToSizes(widths),
44-
srcSet: mapWidthsToSrcSet(widths, src)
46+
srcSet: mapWidthsToSrcSet(widths, src),
47+
src: getSrcWithoutOptionalParams(src)
4548
}
4649
}
4750

0 commit comments

Comments
 (0)