npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netlify-plugin-imageengine

v0.2.0

Published

Netlify Build plugin - Imageengine optimize your images by up to 80% on autopilot for improved SEO, lower bounce rates, better mobile experience, and increased sales

Downloads

5

Readme

Netlify ImageEngine Plugin

The Netlify ImageEngine plugin optimizes your images by up to 80% on autopilot, enhancing SEO, reducing bounce rates, improving mobile experiences, and boosting sales.

Deploy to Netlify

Installation

Install this plugin from Netlify.

NPM : npm i netlify-plugin-imageengine

example netlify.toml

[[plugins]]
package = "netlify-plugin-imageengine"

  [plugins.inputs]
  deliveryAddress = "blazing-fast-pics.cdn.imgeng.in"

  [plugins.inputs.directives]
  height = 600
  width = 700
  rotate = 90

Configuration

The following inputs options are available:

  • deliveryAddress: The ImageEngine delivery address.
  • directives: Optional image transformation directives.

Features

Image Optimization

  • Automatic URL Replacement: The plugin scans HTML files and replaces image URLs with optimized ImageEngine URLs using the updateHtmlImagesToImageEngine function.

  • srcset Handling: It updates srcset attributes to ensure all image sources are optimized, improving loading times and image quality across different devices.

  • Error Handling: The plugin logs errors encountered during the URL transformation process, ensuring smooth operation and easy debugging.

Build Process Integration

  • Netlify Build Plugin: The onPostBuild function integrates with Netlify's build process, automatically optimizing images after the build completes.

  • Environment Context Awareness: The plugin adapts to different Netlify deployment contexts (e.g., branch deploys, deploy previews) by using the appropriate host URL.

  • Configuration Validation: It checks for necessary configurations like deliveryAddress and PUBLISH_DIR, failing gracefully with informative error messages if they are missing.

Code Overview

updateHtmlImagesToImageEngine

This function takes HTML content and options, then updates image URLs to use ImageEngine for optimization. It handles both src and srcset attributes, ensuring all images are optimized.

processBundle

This function processes JavaScript bundle content, replacing image URLs with optimized ImageEngine URLs. It uses regular expressions to identify image URLs and applies the transformSrcURL and build_IE_url functions to generate the optimized URLs. This ensures that all images in the JavaScript bundles are optimized for better performance and quality.

transformSrcURL

This function transforms original image URLs to use the ImageEngine delivery address. It handles different types of URLs:

  • Remote URLs: Transforms fully-qualified URLs (e.g., starting with "http://" or "https://") and protocol-relative URLs (e.g., starting with "//").
  • Local URLs: Transforms local paths to use the ImageEngine delivery address, ensuring all images are served through ImageEngine for optimization.

It ensures that the final URL is correctly formatted and ready for ImageEngine processing.