Shopify2023-10-18Problem & solution
Images as Code: Representing Localized and Evolving Products on Marketing Pages
Summary
Shopify needed product visuals on more than 35 localized domains to stay accurate as features, currencies, languages, and product UI changed. An SVG experiment made translated text difficult to manage because SVG lacks word wrapping, while export settings, effects such as Gaussian blur, and repeated translation hooks created maintenance and performance problems. The replacement represented interfaces in HTML and JavaScript through ScaleContentAsImage, which wraps fixed-width content, computes available space, applies a CSS transform scale, preserves layout with a spacer, absolutely positions the transformed element, and updates calculations on resize. The team concluded HTML/JavaScript was more maintainable and flexible for design, documentation, animations, and localization, while noting remaining work around lazy-loaded images, reusable-visual documentation, and future CSS Houdini possibilities.
Context
Product visuals on shopify.com had become outdated, while maintaining screenshots or separate translated image assets across more than 35 localized domains was inefficient. Domains could differ in currencies, features, and languages, and the SVG-based alternative introduced broken long translations, export-process complexity, and performance issues.
Approach / What changed
The team replaced exported SVG visuals with HTML and JavaScript, using the ScaleContentAsImage utility. It places fixed-width visual content in a wrapper, calculates the available width, applies a proportional CSS transform, preserves page layout with spacer and absolute-positioning logic, and recalculates sizing when the window changes.
Takeaways
SVG does not support word wrapping, so longer translations such as German text could overflow; Gaussian blur effects also caused performance issues in Firefox.
ScaleContentAsImage preserves the visual’s designed proportions by scaling a fixed-width wrapper and compensating for CSS transforms that otherwise do not change document flow.
The HTML/JavaScript approach removed SVG export documentation and design restrictions, while leaving performance and structural work around lazy-loaded images and documenting reusable visuals.
Source and freshness
- Source
- shopify.engineering
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.