• Stars
    star
    159
  • Rank 235,916 (Top 5 %)
  • Language
    JavaScript
  • Created almost 10 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Remove inline SVG bloat from your HTML document

deSVG

What does it do?

deSVG takes the <img /> tags you supply. It then grabs, using AJAX, the raw SVG you've set in the src attribute and replaces that <img /> with the <svg /> it downloads.

Install

Grab the files from this repo, or install from npm

Usage

window.addEventListener('load', function(){
 	// 1. selector for the <img /> tags to replace
 	// 2. whether to strip inline style tags from SVG paths
	deSVG('.replace-svg', true);
});

If you do not wish for two network requests to be made per image, instead of using the src attribute, you can pass in the images path via data-src="path/to/file". Note that this may cause layouts to jump and no image to be displayed whilst it is being fetched.

Demo

Check out this JSFiddle.

Source

Check out the commented source which should explain it's functionality in greater detail.

More Repositories

1

grade

This JavaScript library produces complementary gradients generated from the top 2 dominant colours in supplied images.
JavaScript
3,769
star
2

svgeezy

Allows for automatic Image fallbacks for browsers that can't handle SVGs
JavaScript
875
star
3

touche

Effortlessly re-map click events to touch events on touchscreen UIs
JavaScript
605
star
4

Adaptive-Backgrounds

A JavaScript plugin for extracting the dominant color from images and applying the color to their parent.
CSS
245
star
5

isomorphic-js-app

A JS/Node app that uses Backbone.js/React.js/Browserify to make it Isomorphic
JavaScript
22
star
6

filtergram

For People Who Want To See Some Instagram Content But Aren't Too Keen On The Instagram Experience Itself.
JavaScript
22
star
7

cortado

A sans-jQueryβ„’ View & Event library for JavaScript web applications
JavaScript
20
star
8

typo

Typography CSS library
16
star
9

Chatt

A tiny chat app written in Meteor for my 12Devs article.
JavaScript
15
star
10

ihi

Easy location sharing
CSS
14
star
11

speculo

Colour palette visualiser
JavaScript
14
star
12

Seo.js

SEO checklist for your website, not for production
JavaScript
13
star
13

fwd

A dead simple JavaScript plugin to help manage page-specific JavaScript code in the browser.
JavaScript
13
star
14

musings

Musings - advice & inspiration from people in the web industry
CSS
11
star
15

palette

HTML
10
star
16

readmeapp-site

JavaScript
9
star
17

varr

A basic variable replacement preprocessor for CSS files
JavaScript
7
star
18

readmeapp-api

JavaScript
7
star
19

thrift

GitHub repo/idea thrift store for the open web.
JavaScript
6
star
20

jekyll-search-demo

A Jekyll project demoing a dynamic search page
CSS
5
star
21

facebookInfo

A small class designed to take the pain away from working with the Facebook API.
PHP
5
star
22

React-Redux-Conversational

JavaScript
5
star
23

js-idioms

CSS
5
star
24

gustavo

A form validation library for Backbone Views.
JavaScript
5
star
25

everyday-stoic

JavaScript
4
star
26

disconnect-today

Twitter digest emails without the distraction
JavaScript
4
star
27

placevaughnandfranco

Vaughn & Franco place it image service website
JavaScript
4
star
28

ubiq

Easily share tracks, artists or albums across different music services
JavaScript
3
star
29

BB-Express

Boilerplate app for Backbone & Express
JavaScript
3
star
30

top-spot

Top Spot looks through your Spotify playlists, finds the most frequently occurring tracks, and creates you a playlist from them.
JavaScript
2
star
31

beattheclock

A beat-the-clock game designed to help people learn JavaScript
JavaScript
2
star
32

albums

JavaScript
2
star
33

moodboard

JavaScript
2
star
34

referrral-app

Backbone.js front-end for Referrral
JavaScript
2
star
35

halcyon

JavaScript
2
star
36

aviewtoakill

A boilerplate Backbone.js app for pushState and Dan Harper's ViewManager
JavaScript
2
star
37

cmyk

JavaScript
1
star
38

Costarred

CSS
1
star
39

venetian

JavaScript
1
star
40

Class

Simple, elegant inheritance for your JavaScript
CSS
1
star
41

atme

JavaScript
1
star
42

miniload

PHP
1
star
43

Foto

A HTML/CSS Template for kickstarting a project
PHP
1
star
44

shade

JavaScript
1
star
45

secretFilmProject

JavaScript
1
star
46

ihi-ios

iOS app as a companion for iHi
Objective-C
1
star