whoami

Lucas Jenß

cat /etc/motd

The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.

Close-up of white dominoes with black dots standing on green felt surface, shallow depth of field, focused mood

ls -la ~/languages/

total 8
drwxr-xr-x
▶ PHP
▶ Ruby
▶ Scala
▶ C#
▶ JavaScript
▶ Objective-C
▶ Shell Scripting

ls -la ~/toolchain/

total 7
drwxr-xr-x
▶ Typo3
▶ Akka
▶ Capistrano
▶ Git
▶ MAMP
▶ Adobe Illustrator
▶ NSTrackingArea (Cocoa)

uname -a

platforms
drwxr-xr-x
▶ Mac OS X
▶ Unix

Creating Animated SVG Sprites with Illustrator and Inline CSS

Animated SVG sprites are a practical way to add movement to interface icons, loading indicators, product controls, and small illustrations without shipping a collection of raster images. Illustrator is useful for drawing and exporting the artwork, while inline CSS provides the timing, easing, and state changes needed in the browser.

The technique suits sites where crisp visuals matter across phones, tablets, and large screens. That is especially relevant for Australian projects, where a page may be tested on a fast NBN connection in Melbourne, a busy 4G network in regional Queensland, and a range of older Android devices used by customers who expect a quick, low-data experience.

The workflow is straightforward once the SVG is treated as structured markup rather than a flat picture. Build reusable artwork in Illustrator, export clean paths, combine those paths into a sprite, and animate selected elements with CSS. A little care around naming, accessibility, and debugging prevents most problems later.

Preparing Artwork In Illustrator

Start with a document sized for the visual system rather than the final rendered pixel size. SVG is resolution-independent, so a 24-pixel icon and a 240-pixel illustration can share the same source artwork. Use a small number of layers and give important objects descriptive names such as wheel, spark, stroke-main, or panel-highlight.

Illustrator’s layer names can become IDs during export, although the result should always be checked manually. Avoid spaces, punctuation, and duplicate names. Expand strokes when their exact outline must remain stable during animation, but retain simple strokes when you intend to animate stroke-dasharray or stroke-dashoffset.

Before exporting, remove hidden objects, unused swatches, clipping masks that are no longer required, and excessive anchor points. Simplifying paths can reduce file size substantially. Keep the artboard close to the artwork so the viewBox does not include a large empty margin.

Export each component as SVG, then inspect the markup in a code editor. Illustrator may include metadata, XML declarations, editor-specific namespaces, and verbose inline styles. These do not always break the result, but removing unnecessary content makes a sprite easier to understand and maintain. A minifier can help after the structure has been tested.

Building A Reusable SVG Sprite

A sprite stores several graphical definitions in one hidden SVG element. The usual pattern is a <defs> block containing <symbol> elements. Each symbol receives an ID and a viewBox, allowing it to be rendered later with a normal <use> element.

<svg aria-hidden="true" class="svg-sprite">
  <defs>
    <symbol id="icon-sync" viewBox="0 0 64 64">
      <path class="ring" d="M32 8a24 24 0 1 1-17 7"/>
      <path class="arrow" d="M15 7v12h12"/>
      <circle class="dot" cx="32" cy="32" r="4"/>
    </symbol>
  </defs>
</svg>

The sprite can be placed near the beginning of the document or included through a server-side partial. A visible icon then references the symbol:

<svg class="icon icon-sync" role="img" aria-labelledby="sync-title">
  <title id="sync-title">Synchronising</title>
  <use href="#icon-sync"></use>
</svg>

For purely decorative artwork, use aria-hidden="true" and provide the meaning through nearby text. For controls, the button needs an accessible label even when the icon itself has no title. This matters for Australian public-facing services, where the Disability Discrimination Act 1992 supports the expectation that digital content should be usable with assistive technology.

Inline sprites are generally easier to style than external SVG files because CSS can reach their internal paths. An external <use> reference may be subject to browser restrictions or prevent selectors from behaving as expected. If caching is more important than direct styling, an external file can still be suitable, but test it in the target browsers before committing to that architecture.

Adding Motion With Inline CSS

Place the animation rules in a <style> element inside the inline SVG or in the page stylesheet. Class-based selectors make the relationship between the Illustrator artwork and the animation clear:

<style>
  .icon-sync .ring {
    transform-origin: 32px 32px;
    animation: rotate-ring 1.4s linear infinite;
  }

  .icon-sync .arrow {
    animation: pulse-arrow 1.4s ease-in-out infinite;
  }

  @keyframes rotate-ring {
    to { transform: rotate(360deg); }
  }

  @keyframes pulse-arrow {
    0%, 100% { opacity: .45; }
    50% { opacity: 1; }
  }
</style>

SVG transforms can behave differently from HTML transforms, so set transform-origin explicitly. For complex objects, transform-box: fill-box may produce a more predictable result. Keep the transform origin in the SVG’s coordinate system and test the motion at the actual rendered size.

CSS variables are useful when the same sprite needs different themes:

.icon-sync {
  --accent: #087f8c;
  color: var(--accent);
}

.icon-sync .ring {
  stroke: currentColor;
}

Use currentColor for icons that should follow surrounding text and custom properties for variations such as warning, success, or dark-mode states. A loading animation should stop when its job is finished; leaving every animated icon running can waste battery and create visual noise, particularly on mobile devices used during a commute through Sydney or Brisbane.

Respect reduced-motion preferences with a media query:

@media (prefers-reduced-motion: reduce) {
  .icon-sync .ring,
  .icon-sync .arrow {
    animation: none;
  }
}

A static frame, a gentle opacity change, or a clear status label can replace continuous movement. This also improves usability for people who experience discomfort from looping motion.

Troubleshooting Export And Runtime Errors

When an animation fails, first inspect the final browser DOM rather than the Illustrator file. Confirm that the expected ID exists, the <use> element points to it, and the animated class has survived any optimisation step. A missing namespace, duplicated ID, or selector aimed at the wrong nesting level can make valid-looking CSS appear ineffective.

If the graphic displays but does not animate, check whether the style is scoped correctly. A selector such as .icon-sync .ring will not match a path if the <use> reference hides the original nodes from the styling context in the chosen browser setup. Inline symbols usually avoid this issue, but a minimal test page will reveal whether the problem belongs to the sprite, the CSS, or the application template.

Large SVGs can also create server-side symptoms before the browser receives anything. If an older TYPO3 installation starts failing while rendering a page with repeated inline assets, separate the front-end animation issue from the PHP memory problem and review legacy TYPO3 memory debugging. Repeated parsing, duplicated markup, or an inefficient asset helper may be responsible.

Animation state can be just as important as visual styling. A synchronising icon should start, pause, and finish in response to application events rather than merely looping forever. When those events arrive asynchronously, the same careful reasoning used to diagnose a stalled Akka mailbox can help: identify the producer, the state transition, and the code that should clear or update the visual indicator.

Testing Performance And Accessibility

Test the sprite with keyboard navigation, screen readers, browser zoom, forced colours, and a reduced-motion setting. Check that focus indicators remain visible and that an animated decoration does not carry the only meaning. For an order status, write “Payment processing” in text instead of relying on a spinning ring.

Measure the rendered page with browser developer tools. Look for repeated copies of the same symbol, expensive filters, oversized path data, and animations that trigger layout or paint work unnecessarily. Transforming opacity and simple geometry is usually safer than animating filters, blur, or large path definitions on every frame.

Australian users often move between desktop and mobile contexts, so test both a high-density iPhone and a modest Android handset. A Sydney design studio may review the work on a current MacBook, while a regional customer may load it through a congested mobile connection. The SVG should remain useful when fonts, scripts, or non-essential imagery load slowly.

For commercial sites, also check how the visual treatment fits local expectations around consent, checkout clarity, and privacy. Animation should never obscure a cookie choice, payment status, or form error. If a business serves customers across different Australian states, consistent contrast and clear status feedback are more valuable than decorative complexity.

Keeping The Workflow Maintainable

Store the Illustrator source separately from the cleaned SVG sprite, and document the export settings. A future edit should make it obvious which file is authoritative and which file is generated. Version control is particularly useful for catching accidental changes to IDs, viewBox values, or path winding directions.

Use a naming convention that separates icon purpose from state. Names such as upload-idle, upload-active, and upload-success are easier to search than generic labels like layer-17. If several icons share a visual element, consider a reusable <g> definition, but avoid creating an abstraction so intricate that a simple illustration becomes difficult to edit.

Automate cleanup and checks where possible. A build step can optimise path data, remove Illustrator metadata, detect duplicate IDs, and fail when an expected symbol disappears. It can also generate a small preview page showing every symbol in normal, hover, focus, active, and reduced-motion states.

Once the sprite is stable, reuse it consistently across the site rather than recreating an icon in each template. This keeps branding coherent for Australian agencies, retailers, and community organisations while reducing transfer size and maintenance effort. A carefully prepared Illustrator file, a compact inline sprite, and a small set of CSS keyframes are enough to produce polished motion without adding a heavy animation library.

Build one small animated icon first, inspect its exported markup, and test it in the browsers your site actually supports. Then add the finished symbol to your shared sprite, connect its state changes to real application events, and verify the reduced-motion and accessible versions before publishing it to production.


cat ~/interests.json

KeyValue
editorTerminal-first workflow
osMac OS X / Unix
vcsGit, distributed version control
deployCapistrano, cron automation
graphicsSVG, Adobe Illustrator troubleshooting
networkingIP validation, SSH, VPN

git log --oneline --reverse

2013-10-30

Solving SVG import issues in Adobe Illustrator CS6 and CC

When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.

2013

Solving NDK build issues on OS X

Troubleshooting native development kit compilation problems on Mac OS X.

2013

Programmatically adding PHP generated TypoScript to the backend configuration

Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.

2013

ArgumentError: Could not parse PKey: no start line

Debugging an SSH key parsing error encountered during deployment.

2011-08-04

Validating IP-Addresses in PHP

Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.

2011-07-09

Cocoa: Using NSTrackingArea

A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.


cat ~/contact.txt

github: github.com/x3ro
stackoverflow: x3ro
coderwall: coderwall.com/x3ro
twitter: @x3rames