{"id":363526,"date":"2022-02-24T07:31:49","date_gmt":"2022-02-24T15:31:49","guid":{"rendered":"https:\/\/css-tricks.com\/?p=363526"},"modified":"2022-02-24T07:31:52","modified_gmt":"2022-02-24T15:31:52","slug":"superior-image-optimization-an-ideal-solution-using-gatsby-imageengine","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/superior-image-optimization-an-ideal-solution-using-gatsby-imageengine\/","title":{"rendered":"Superior Image Optimization: An Ideal Solution Using Gatsby & ImageEngine"},"content":{"rendered":"\n
In recent years, the Jamstack<\/a> methodology for building websites has become increasingly popular. Performance, scalable, and secure, it\u2019s easy to see why it\u2019s becoming an attractive way to build websites for developers.<\/p>\n\n\n\n GatsbyJS is a static site generator platform. It\u2019s powered by React, a front-end JavaScript library, for building user interfaces. And uses GraphQL, an open-source data query and manipulation language, to pull structured data from other sources, typically a headless CMS like Contentful.<\/p>\n\n\n\n While GatsbyJS and similar platforms have revolutionized much about the web development process, one stubborn challenge remains: image optimization. Even using a modern front-end development framework like GatsbyJS, it tends to be a time-intensive and frustrating exercise.<\/p>\n\n\n\n For most modern websites, it doesn\u2019t help much if you run on a performant technology but your images aren\u2019t optimized. Today, images are the largest contributor to page weight, and growing<\/a>, and have been singled out by Google as presenting the most significant opportunity for improving performance<\/a>.<\/p>\n\n\n\n With that in mind, I want to discuss how using an image CDN as part of your technology stack can bring improvements both in terms of website performance and the entire development process.<\/p>\n\n\n\n\n\n\n GatsbyJS is so much more than the conventional static site generators of old. Yes, you still have the ability to integrate with a software version control platform, like Git, as well as to build, deploy, and preview Gatsby projects. However, its services consist of a unified cloud platform that includes high-speed, scalable, and secure hosting as well as expert technical support and powerful third-party integrations.<\/p>\n\n\n\n What\u2019s more, all of it comes wrapped in a user-friendly development platform that shares many similarities with the most popular CMSs of the day. For example, you can leverage pre-designed site templates or pre-configured functions (effectively website elements and modules) to speed up the production process.<\/p>\n\n\n\n It also offers many benefits for developers by allowing you to work with leading frameworks and languages, like JavaScript, React, WebPack, and GraphQL as well as baked-in capabilities to deal with performance, development iterations, etc.<\/p>\n\n\n\n For example, Gatsby does a lot to optimize your performance without any intervention. It comes with built-in code-splitting, prefetching resources, and lazy-loading. Static sites are generally known for being inherently performant, but Gatsby kicks it up a notch.<\/p>\n\n\n Gatsby does, in fact, offer built-in image optimization capabilities.<\/p>\n\n\n\n In fact, it recently upgraded in this regard, replacing the now deprecated gatsby-image package with the brand-new Gatsby image plugin. This plugin consists of two components for static and dynamic images, respectively. Typically, you would use the dynamic component if you\u2019re handling images from a CMS, like Contentful.<\/p>\n\n\n\n Installing this plugin allows you to programmatically pass commands to the underlying framework in the form of properties, shown below:<\/p>\n\n\n\nA Quick Introduction to Gatsby<\/h2>\n\n\n
Does Gatsby Provide Built-in Image Optimization?<\/h3>\n\n\n