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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(image): reduce svgo precision for tracedSVGs #4270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/gatsbygram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"dependencies": {
"gatsby": "^1.9.52",
"gatsby-image": "^1.0.5",
"gatsby-image": "^1.0.39",
"gatsby-link": "^1.6.20",
"gatsby-plugin-glamor": "^1.6.8",
"gatsby-plugin-google-analytics": "^1.0.8",
Expand Down
14 changes: 7 additions & 7 deletions examples/gatsbygram/src/components/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as PropTypes from "prop-types"
import React from "react"
import HeartIcon from "react-icons/lib/fa/heart"
import Link from "gatsby-link"
import Img from "gatsby-image"

import { rhythm, scale } from "../utils/typography"
import presets from "../utils/presets"
Expand Down Expand Up @@ -42,7 +43,6 @@ class Post extends React.Component {
}}
css={{
display: `block`,
backgroundColor: `lightgray`,
flex: `1 0 0%`,
marginRight: rhythm(1 / 8),
width: `100%`,
Expand All @@ -61,14 +61,11 @@ class Post extends React.Component {
flexDirection: `column`,
flexShrink: 0,
position: `relative`,
paddingBottom: `100%`,
overflow: `hidden`,
}}
>
<img
src={small.src}
srcSet={small.srcSet}
sizes="(min-width: 960px) 292px, 33vw"
<Img
sizes={{ ...small }}
css={{
margin: 0,
height: `100%`,
Expand Down Expand Up @@ -133,9 +130,12 @@ export const postFragment = graphql`
likes
smallImage: image {
childImageSharp {
small: responsiveSizes(maxWidth: 292, maxHeight: 292) {
small: sizes(maxWidth: 292, maxHeight: 292) {
src
srcSet
aspectRatio
sizes
tracedSVG
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ function encodeOptimizedSVGDataUri(svgString) {

const optimize = svg => {
const SVGO = require(`svgo`)
const svgo = new SVGO({ multipass: true, floatPrecision: 1 })
const svgo = new SVGO({ multipass: true, floatPrecision: 0 })
return new Promise((resolve, reject) => {
svgo.optimize(svg, ({ data }) => resolve(data))
})
Expand Down