When two pages in vue use larger packages, is there any optimization?

In the

vue project, there are two pages, both of which use an editor plug-in, but the size of the editor plug-in is large, which affects the loading speed, and both pages are used, so the editor is encapsulated into a component, thinking that loading the other page only once will be faster, but this does not seem to be the case, as follows:

how should I optimize in such a situation? Encapsulated into components, introducing components into two pages seems to be similar to using plug-ins directly on the page. Solve it, thank you.

May.30,2022

Asynchronous load component
components: {
aaa: resolve= > {

require(['./aaa.vue'],resolve)

}
}


Webpack CommonsChunkPlugin


package the editor into a component according to the logic you need, such as my-editor
An and B pages lazily load the editor component

const MyEditor = () => import('@/xx/my-editor')

components: {
    MyEditor
}

on cdn


Don't underestimate webpack. As long as you are not copying and pasting the code, webpack can do a great job of packing and reloading.

Menu