question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option for symbol based output for use with <use>

See original GitHub issue

Do you want to request a feature, report a bug or ask a question? Feature

What is the current behavior? Symbol markup in the sprite is wrapped in <defs>, includes a <style> block, and includes a <use> for each svg item. The reasoning for this is explained in https://github.com/kisenka/svg-sprite-loader/issues/122 .

What is the expected behavior? If the developer will only be refering items in the sprite via <use xlink:href="sprite.svg#item-name"/> and not in CSS or <img> then allow svg-sprite-loader to generate a simpler output without the things mentioned above (defs, style, use).

If this is a feature request, what is motivation or use case for changing the behavior? No need for the extra markup bloat when only using <use xlink:href="sprite.svg#item-name"/>; smaller file size.

Please tell us about your environment:

  • Node.js version: 8.5
  • webpack version: 3.6
  • svg-sprite-loader version: 3.2.5
  • OS type & version: Linux, Fedora Linux x86_64

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc) Example of current output:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style>
    .sprite-symbol-usage {display: none;}
    .sprite-symbol-usage:target {display: inline;}
  </style><symbol viewBox="0 0 24 24" fill="none" stroke="currentColor" id="anchor">
    <circle cx="12" cy="5" r="3" />
    <line x1="12" y1="22" x2="12" y2="8" />
    <path d="M5 12H2a10 10 0 0 0 20 0h-3" />
</symbol></defs><use id="anchor-usage" xlink:href="#anchor" class="sprite-symbol-usage" /></svg>

Example of proposed simplified output:

<svg xmlns="http://www.w3.org/2000/svg" style="display:none">
  <symbol id="anchor" viewBox="0 0 24 24" fill="none" stroke="currentColor">
    <circle cx="12" cy="5" r="3" />
    <line x1="12" y1="22" x2="12" y2="8" />
    <path d="M5 12H2a10 10 0 0 0 20 0h-3" />
  </symbol>
</svg>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kisenkacommented, Dec 13, 2017

Closing this one, there is a bug described by @MaxMilton, please follow #221

1reaction
maxmiltoncommented, Sep 29, 2017

Inline is not a good idea if you have icons which repeat, no point defining the same code multiple times. The <use> technique is great since SVG resources only need to be defined once and you can style the same SVG item in different ways.

I’m not sure that this package is the right place to do file inlining as its purpose is to create an SVG sprite, although there may be some SVG parsing logic you could use to write a custom loader.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Symbol Processing (Linker and Libraries Guide)
You can use the link-editor's -m option to write a list of all interposed symbol references, along with section load address information, to...
Read more >
Using LD, the GNU linker - Command Line Options
Create a global symbol in the output file, containing the absolute address given by expression . You may use this option as many...
Read more >
Output symbology in scripts—ArcGIS Pro | Documentation
An output parameter can have an associated symbology. When the tool is run, the output is added to the display using the specified...
Read more >
Flowchart Symbols & Meaning - Complete Guide 2022
5. Input / Output Symbol: Indicates the process of inputting or outputting external data. This is indicated by the shape of a parallelogram....
Read more >
Options (LD) - sourceware.org
You can also use the dynamic list to control what symbols should be added to the dynamic symbol table if the output format...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found