GithubHelp home page GithubHelp logo

dr-js / libsvgo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svg/svgo

7.0 1.0 2.0 3.78 MB

[Use svgo@2 dist browser bundle] The core code of SVGO, optimized to be portable

License: Other

JavaScript 100.00%

libsvgo's Introduction

libsvgo

i:npm i:ci i:size i:npm-dev

The core code of SVGO, optimized to be portable


  • ๐Ÿ“ lib/ & plugins/
    • main source code, in output package will be:
      • libsvgo/lib/ & libsvgo/plugins/: for direct use, use require() / exports.*=
      • libsvgo/module/lib/ & libsvgo/module/plugins/: for use with node + @babel/register, keep import / export and readability
      • libsvgo/webpack/SVGO.js: all-in-one packaged version, can be used in browser like <script src="https://unpkg.com/libsvgo/webpack/SVGO.js"></script>, and provide window.SVGO (experimental)
  • ๐Ÿ“ test/
    • test code & resource file
  • ๐Ÿ“ examples/
    • code example

This repo is a heavily changed fork of SVGO, mainly:

  • ES6+ code update & re-format
  • drop cli and option parsing code to reduce size
  • drop node-specific module to allow both Browser and Node use

And is expected to be used by nodejs@>=12 or recent-enough Browser


sample usage: (ES6 module)

// get most used from main entry
import { SVGO, SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST } from 'libsvgo/module/lib/svgo'

// or get each separately
import { SVGO_LITE } from 'libsvgo/module/lib/svgo-lite'
import { SVGO_LITECONFIG_LITE } from 'libsvgo/module/lib/svgo/config-lite'

// get each plugin separately
import * as addAttributesToSVGElement from 'libsvgo/module/plugins/addAttributesToSVGElement'

sample usage: (Node.js module through Babel)

// get most used from main entry
const { SVGO, SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST } = require('libsvgo/lib/svgo')

// or get each separately
const { SVGO_LITE } = require('libsvgo/lib/svgo-lite')
const { SVGO_LITECONFIG_LITE } = require('libsvgo/lib/svgo/config-lite')

// get each plugin separately
const addAttributesToSVGElement = require('libsvgo/plugins/addAttributesToSVGElement')

sample usage: (ES6 Webpack bundle)

// `require()` in nodejs
const SVGO = require('libsvgo/webpack/SVGO')
// or load from `<script src="https://unpkg.com/libsvgo/webpack/SVGO.js"></script>` in browser

// get common lib (not all is exposed)
const { SVGO_LITE, CONFIG_LITE, PLUGINS_DEFAULT_LIST, PLUGINS_MAP } = SVGO

// get plugin
const { addAttributesToSVGElement } = PLUGINS_MAP

also check examples/ for basic usage

libsvgo's People

Contributors

alexjlockwood avatar aprilarcus avatar bennyschudel avatar branneman avatar caub avatar davidleston avatar deepsweet avatar dfilatov avatar dr-js avatar elidupuis avatar greli avatar jakearchibald avatar joshyphp avatar kt3k avatar lahmatiy avatar meomix avatar nathan-muir avatar phihag avatar scurker avatar silentroach avatar strarsis avatar thiakil avatar tigt avatar vithar avatar volker-e avatar vzaidman avatar yandavid avatar ydaniv avatar yeti-or avatar zearin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.