Skip to content

minifyJS

Reuben L. Lillie edited this page Jul 22, 2019 · 2 revisions

Summary

The minifyJS() filter optimizes and loads a JavaScript file inline.

Code resides in filters/minify-js.js where there is more technical inline documentation.

Use

To use minifyJS() as a universal filter in 11ty, make sure you install Mihai Bazon’s uglify-es module.

~$ npm install --save uglify-es

Call this.minifyJS() wherever you can load an inline script.

// layout.11ty.js

module.exports = function (data) {
  return `
<!DOCTYPE>
    <html>
      <head>

      </head>
      <body>

         <script>
          ${this.minifyJS(this.fileToString('/includes/assets/js/script.js'))} 
         </script>
      </body>
    </html>`
}
  1. Welcome
  2. Setup
  3. Coding Standards
    • HTML (in /pghnaz.org/wiki)
    • CSS (in /pghnaz.org/wiki)
    • JavaScript (in /pghnaz.org/wiki)
  4. Color Scheme
  5. Style Guide
  6. Layouts
    • 404.11ty.js
    • base.11ty.js
    • calendar.11ty.js
    • contact.11ty.js
    • content.11ty.js
    • collection.11ty.js
    • eventList.11ty.js
    • map.11ty.js
    • search.11ty.js
  7. Filters
  8. Shortcodes
  9. Client-Side JavaScript
    • search.js
  10. Other static assets
    • Badges
    • Branding
    • Fonts
Clone this wiki locally