Category:SVG created with JavaScript

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Self-generating SVG pioneered by TilmannR (talk · contribs) and further developed by cmglee (talk · contribs) which uses JavaScript to replace itself with static SVG, and embed itself as a comment.

This avoids users needing any software except a web browser and a text editor to update and rerun the script.

Editing workflow:

  1. Open a template file or existing file to be amended in a text editor.
  2. Amend code in user-editable parts as needed.
  3. Delete the "!--" and "--" on lines indicated.
  4. Save as a new file or file to be amended.
  5. Open the file in Firefox or Chrome.
  6. In the web browser, save as another file.
  7. Upload this file to Commons.

Drawbacks of this method:

  • Escaped non-ASCII characters are converted to their UTF-8 equivalents so the file may no longer be ASCII (giving mojibake in some text editors).
  • The JavaScript must not have two consecutive hyphens (--).
  • Errors may be difficult to debug for editors unfamiliar with JavaScript; pressing F12 and selecting the Console tab may give clues.

Media in category "SVG created with JavaScript"

The following 8 files are in this category, out of 8 total.