Git Product home page Git Product logo

svg-icon-optimizer's Introduction

@html-next/svg-icon-optimizer

SVG Icon Performance Optimization

This addon lets ember app's progressively opt in to highly optimized icon usage via a combination of embroider, template-only components, and build-time plugins.

TL;DR

  • Put svg icons in your app as template-only components app/components/icon/**/*.hbs
  • Use icons in your app as a regular component e.g. <Icon::Fa::Trashcan />

Optimizations

    1. less-repetitive inline-svg usage - which keeps your payloads smaller. You get this just by using icons as components. You don't even need this addon for that <3 !
    1. tree-shake unused icons. You get this purely by using embroider for your build, no other configuration required! You don't even need this addon for that <3 !
    1. don't ship SVGs as JS code. Using this addon your SVGs will be extracted to public/assets/component-icons/**/*.svg. This reduces the JS bundle size and allows for these images to be served from cache. We'll even keep a stable fingerprint for them between builds if they haven't changed. The magic here is use, your components are converted into this still tree-shakeable form:
<svg ...attributes xmlns="http://www.w3.org/2000/svg">
  <use xlink:href="assets/component-icons/fa/trashcan.svg"></use>
</svg>

This form allows us to re-use SVG images and cache them while retaining the ability to style them inline.

    1. Automatically convert only the used SVGs into symbols and a sprite. We'll parse your templates and find which icons were actually used, then create a sprite for them. The output from the optimization in step-3 changes to:
<svg ...attributes xmlns="http://www.w3.org/2000/svg">
  <use xlink:href="assets/component-icon-sprite.svg#fa-trashcan"></use>
</svg>

Compatibility

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Installation

ember install @html-next/svg-icon-optimizer

Usage

[Longer description of how to use the addon in apps.]

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

svg-icon-optimizer's People

Contributors

runspired avatar ember-tomster avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.