Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG Sprite in JavaScript #148

Open
guoyunhe opened this issue Feb 21, 2020 · 1 comment
Open

SVG Sprite in JavaScript #148

guoyunhe opened this issue Feb 21, 2020 · 1 comment
Assignees
Labels
suggestion Suggest new features for our website

Comments

@guoyunhe
Copy link

guoyunhe commented Feb 21, 2020

Is your feature request about the Usage? Please describe.

If the website and SVG sprite are hosted in different servers (many big sites use dedicated server for static files), browser will prevent cross site reference:

<!-- http://en.opensuse.org/ -->
<svg class="remix">
  <use xlink:href="http://static.opensuse.org/svg/sprite.svg#stack-line"></use>
</svg>

Describe the solution you'd like

The solution is very easy. Provide JavaScript sprite.js:

(function(){
  var container = document.create('div');
  container.style.display = 'none';
  container.innerHTML = '<put svg sprite content here>';
  document.append('container');
})();
@xiaochunjimmy
Copy link
Member

Thank you for your suggestion.
We'll talk about this.

@xiaochunjimmy xiaochunjimmy added the suggestion Suggest new features for our website label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggest new features for our website
Projects
None yet
Development

No branches or pull requests

2 participants