Back to the contents of Vue

# How to get rid of xTerm.js for optimizing the bundle size of the Vue2 app.

The size of xTerm.js is slightly big. If your app is slow to start due to bundle download time, you can remove it from the bundle by using xTerm.js with the CDN.

Add the CDN link to the file index.html under the public folder. Then, set the object { Terminal } ``` to the global variablewindow.xterm`` For example:


    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">

    <!-- Xterm -->
    <script src=""></script>
    <script> window.xterm = { Terminal }; </script>

# Add external setting

Add an external setting of xterm on the vue.config.js file as refer xterm for the external global variable xterm as follows:


module.exports = {
  chainWebpack: (config) => {

# Import Terminal and css on the file using xTerm

In the .vue file using the xterm, import Terminal function as usual from xterm and import css directory from the CDN as follows:



  <div ref="Xterm"></div>

//import 'xterm/css/xterm.css'
import { Terminal } from 'xterm'

export default {
  methods: {
      this.term = new Terminal();$refs.Xterm)

@import '';

Last Updated: 1/22/2023, 9:30:53 AM