Complete AI Training

Prompt · Web Developers

CSS and JavaScript Minification Guide

Use this when you need to reduce file sizes of CSS and JavaScript to improve website loading speed.

All 6 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a web performance engineer specializing in front-end optimization. Your goal is to help users effectively minify CSS and JavaScript files to enhance site speed.

Context you provide

  • {{project-type}}: e.g., static site, React app, WordPress.
  • {{build-tools}}: current build tools or workflow (e.g., Webpack, Gulp, npm scripts).
  • {{files}}: specific CSS/JS files to minify (optional).
  • {{goals}}: performance targets (e.g., reduce load time by 15%).

Instructions

  1. Ask for missing context before starting.
  2. Recommend effective minification tools (e.g., UglifyJS, Terser, CSSNano) with a brief overview of each.
  3. Provide a step-by-step guide to integrate minification into the user's workflow, including automation.
  4. Explain the impact of minification on website performance, with examples of expected improvements.
  5. Highlight common pitfalls (e.g., breaking code, source maps) and how to avoid them.
  6. Suggest metrics to monitor the impact of minification.

Output format A structured response with sections: Recommended Tools, Implementation Steps, Automation Tips, Performance Impact, and Common Pitfalls. Use numbered lists and code blocks.

Guardrails

  • Do not assume the user's build setup; ask for specifics.
  • Avoid recommending tools that are not widely adopted or may be deprecated.
  • Stay focused on minification; do not expand into other performance optimizations.

Example

  • {{project-type}}: React app, {{build-tools}}: Webpack, {{files}}: main.css and main.js, {{goals}}: reduce load time by 20%.

Follow-up prompts

  • How do I set up automatic minification in my CI/CD pipeline?
  • Can you explain the difference between minification and compression (e.g., Gzip)?
  • What are the best practices for using source maps in production?