# PageSpeed Insights Optimization

**URL:** <https://discourse.threejs.org/t/pagespeed-insights-optimization/78616>\
**Category:** Questions\
**Tags:** optimization, tree-shaking\
**Created:** [February 24, 2025, 3:01pm UTC](https://discourse.threejs.org/t/pagespeed-insights-optimization/78616 "2025-02-24T15:01:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![whisp0092](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/whisp0092/32/55573_2.png) [@whisp0092](https://discourse.threejs.org/u/whisp0092)\
**Post date:** [February 24, 2025, 3:01pm UTC](https://discourse.threejs.org/t/pagespeed-insights-optimization/78616/1 "2025-02-24T15:01:09Z")

</div>

Im using vite project and rollup to bundle my project, it contains only 1 glb model and some basic camera, lightning setup.  
Even after the build process, there is pretty decent amount of unused js code.

```javascript
// vite.config.js
import { defineConfig } from 'vite';
import { resolve } from 'path';

export default defineConfig({
  base: './', 
  build: {
    outDir: 'dist', 
    rollupOptions: {
   
      input: resolve(__dirname, 'index.html'),
      output: {
     
        entryFileNames: 'js/[name]-[hash].js',
        chunkFileNames: 'js/[name]-[hash].js',
    
        assetFileNames: assetInfo => {
          if (assetInfo.name && assetInfo.name.endsWith('.css')) {
            return 'css/[name]-[hash][extname]';
          }
         
          if (assetInfo.name && /\.(png|jpe?g|gif|svg)$/.test(assetInfo.name)) {
            return 'img/[name]-[hash][extname]';
          }
          return '[name]-[hash][extname]';
        }
      }
    },
    
    minify: 'terser'
  }
});

```

```javascript
{
  "name": "threejs-laptop",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "deploy": "node deploy.js",
    "build:deploy": "npm run build && npm run deploy"
  },
  "devDependencies": {
    "@fullhuman/postcss-purgecss": "^7.0.2",
    "autoprefixer": "^10.4.20",
    "cssnano": "^7.0.6",
    "postcss": "^8.5.1",
    "postcss-cli": "^11.0.0",
    "terser": "^5.38.1",
    "vite": "^6.1.0"
  },
  "dependencies": {
    "gsap": "^3.12.7",
    "lil-gui": "^0.20.0",
    "matter-js": "^0.20.0",
    "ssh2-sftp-client": "^11.0.0",
    "stats.js": "^0.17.0",
    "three": "^0.173.0"
  }
}

```

I wonder why its not being properly tree shaked

---

<div class="post-metadata">

**Author:** ![richi-coder](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/richi-coder/32/48048_2.png) [@richi-coder](https://discourse.threejs.org/u/richi-coder)\
**Post date:** [February 25, 2025, 1:04pm UTC](https://discourse.threejs.org/t/pagespeed-insights-optimization/78616/2 "2025-02-25T13:04:31Z")

</div>

Three is heavy!
