David's Blog

Revolutionizing Web Performance: Using Gemini 3.1-Pro-Preview for AI-Generated SVGs

By David Li on 2026-02-22T19:17:25.000Z

Revolutionizing Web Performance: Using Gemini 3.1-Pro-Preview for AI-Generated SVGs

Web animations have long been a double-edged sword for developers. While they drastically enhance user experience and engagement, relying on heavy animation libraries can bloat your bundle size, increase load times, and drag down your Core Web Vitals. Enter AI-generated SVGs, a modern web performance hack that is changing how we build user interfaces.

A prime example of this paradigm shift is the Devcraft repository by me. Designed as a software development consultancy website, this project leans heavily on the bleeding-edge Gemini 3.1-Pro-Preview model to generate intricate, lightweight SVG assets. By doing so, it entirely bypasses the need for time-consuming and resource-heavy web animations.

Let’s dive into how this repository is structured, the tooling driving it, and how the Vite ecosystem takes SVG management to the next level.


Exploring the Devcraft Repository

The devcraft repository is structured as a modern, lightweight frontend application bootstrapped via AI Studio. With a clear focus on performance and minimal overhead, the project utilizes TypeScript for safe, predictable code, standard HTML/CSS, and relies on modern configuration files (tsconfig.json, vite.config.ts) to manage its build process.

Rather than spending hours manually keyframing complex UI sequences or loading bulky external libraries like Lottie or Framer Motion, the developer utilized Gemini 3.1-Pro-Preview to design the visual layer.

Replacing Heavy Web Animations with AI-Generated SVGs

Complex web animations often require heavy JavaScript execution, leading to:

  • Render-blocking issues during the initial page load.
  • High CPU usage, which drains battery life on mobile devices.
  • Longer development times spent tweaking keyframes and states.

By using Gemini 3.1-Pro-Preview, the Devcraft repository highlights a smarter workflow. The developer prompted the AI to generate complex, scalable vector graphics (SVGs) that inherently carry enough visual depth and structure to replace traditional animations.

The Performance Benefits:

  1. Zero JS Overhead: SVGs are rendered natively by the browser’s graphics engine, keeping the main thread free.
  2. Instant Loading: Vector graphics consist of XML code, meaning they have a fraction of the file size compared to GIFs, videos, or JS-driven animation bundles.
  3. Massive Time Savings: Instead of manually designing and timing animations, Gemini 3.1-Pro-Preview instantly generates code-ready vector assets tailored specifically to the prompt. Developers can even ask Gemini to embed native CSS transitions directly inside the SVG code for lightweight, zero-JS interactivity.

Prompts to Generate SVGs

With the improvements to the latest Gemini model, we can now generate complex, animated, and structurally sound SVG graphics purely through text.

For example, a simple prompt like:

Create an svg of a man typing on a computer and then bringing an painting to life, flat ui design.

Results in this highly detailed, animated graphic:

Man bringing a painting to life

Best Prompting Techniques for SVGs & Images

Generating raw SVG code is fundamentally different from prompting image generators like Midjourney or DALL-E. Instead of just describing what you want to see, you must also describe how it should be built.

Here are the best practices for getting production-ready SVGs:

1. Define the Exact Aesthetic & Style

AI models know a vast array of design systems. If you don’t specify a style, you’ll likely get a messy mix of gradients and strokes. Use specific design keywords:

  • Good: Make a cool illustration of a server.
  • Better: Create an SVG illustration of a cloud server using a Flat UI design style, utilizing simple geometric shapes, clean solid colors, and no outlines.
  • Keywords to try: Flat UI, Corporate Memphis, Isometric, Line Art, Neumorphism, Material Design, Pastel Color Palette, Monochromatic.

2. Lay Out the Composition Spatiality

LLMs need to know where to place elements within the coordinate system (viewBox). Guide the layout by explicitly mentioning positioning.

  • Example: "Split the canvas into two halves. On the left side (x=0 to 400), place the user working on a laptop. On the right side (x=400 to 800), place a floating holographic dashboard."

3. Dictate the Technical Constraints

To ensure your SVG drops perfectly into your web project without breaking, set the technical ground rules in your prompt.

  • Specify the ViewBox: "Use a viewBox of 0 0 1000 600."
  • Styling Methods: "Use inline CSS enclosed in a <style> tag." or "Only use standard presentation attributes (fill, stroke) without external CSS."
  • Font Handling: "Use system fonts (system-ui, sans-serif) so no external web fonts are required."

4. Color Palettes and Lighting (Filters)

If you want a specific mood, give the AI exact Hex codes or describe the lighting. Modern LLMs are excellent at applying SVG filters like drop shadows and glows if you ask for them.

  • Example: "Use a dark mode color palette (Background: #0F172A, Accents: #38BDF8 and #F472B6). Add an SVG <feGaussianBlur> filter to create a glowing neon effect behind the data nodes."

5. Orchestrating CSS Animations

The latest models excel at writing complex @keyframes animations directly into the SVG. To get smooth, logical animations, describe the timeline and easing.

  • Actionable Prompting: "Animate the SVG using CSS. Make the gear in the center spin infinitely using a linear timing function. Have the checkmark pop in after a 2-second delay using a cubic-bezier bouncy easing function. Ensure the animation loops seamlessly."
  • Grouping: Remind the AI to group elements for animation: "Wrap the bird elements in a <g> tag and apply a floating transform animation to the group."

6. The “Layered Iteration” Technique

If you want something incredibly complex, don’t ask for it all in one prompt. Build it in layers:

  1. Prompt 1 (Base): "Create a flat UI SVG of an office desk with a computer."
  2. Prompt 2 (Additions): "Great. Now add a coffee cup on the right with animated steam rising from it."
  3. Prompt 3 (Refinements): "Fix the steam animation so it fades to opacity 0 before looping, and change the background to a soft pastel yellow."

Summary Cheat Sheet for SVG Prompting

When crafting your next prompt, try to fill in these blanks:

Create an SVG of [Subject] doing [Action]. Use a [Design Style] aesthetic with a [Specific Color Palette]. Set the viewBox to [Dimensions]. Ensure the composition features [Element A] on the left and [Element B] on the right. Add CSS animations so that [Element] does [Specific Movement] with a [Delay/Easing]. Keep the code clean, use <g> tags for grouping, and rely only on system fonts.

Tooling: Vite and SVG Optimization

Under the hood, devcraft uses cutting-edge frontend tooling to ensure these AI-generated assets are delivered as efficiently as possible.

Vite: The Build Tool of Choice

The presence of vite.config.ts confirms that Vite is the backbone of this project. Vite offers incredibly fast Hot Module Replacement (HMR) during development and utilizes Rollup for highly optimized, tree-shaken production builds. For a project relying heavily on detailed, AI-generated SVGs, Vite’s fast compilation and lightweight output are perfect.

Vite Packages for SVG Management

Handling raw SVGs can sometimes clutter the DOM or lead to caching issues. Within the Vite ecosystem, developers typically leverage specific Vite packages to streamline SVG implementation:

  • vite-svg-loader / vite-plugin-svgr: These plugins are game-changers. They allow developers to import AI-generated SVGs directly as reusable UI components. This means you can easily manipulate, style, and scale the AI’s output using standard frontend props.
  • SVGO (SVG Optimizer): AI models like Gemini are incredibly powerful, but they can occasionally generate SVGs with redundant XML tags, empty groups, or unnecessary metadata. Vite can seamlessly pipe SVGs through SVGO plugins to minify and clean the AI-generated code before it reaches the production build.

How to Run the Devcraft Project

If you want to explore the repository yourself and see AI integration in action, the local setup is straightforward:

  1. Ensure Node.js is installed on your machine.
  2. Clone the repository and install dependencies with npm install.
  3. Create an .env.local file and set your GEMINI_API_KEY to connect to the Gemini API.
  4. Run npm run dev to spin up the local Vite server.

Check Out the Live Preview

The Devcraft repository is a testament to how developers can leverage AI not just for writing boilerplate code, but for actively solving web performance bottlenecks. By swapping out heavy JavaScript animations for Gemini 3.1-Pro-Preview generated SVGs, the result is a lightning-fast, visually appealing digital consultancy site.

🔗 Live Preview Link: https://friendlyuser.github.io/devcraft


Disclaimer: Please note that the live preview page linked above contains advertisements.

© Copyright 2026 by FriendlyUsers Tech Blog. Built with ♥ by FriendlyUser. Last updated on 2026-02-23.