import{_ as t,c as n,j as s,a as i,G as l,ag as p,B as o,o as d}from"./chunks/framework.C1C4sYC0.js";const v=JSON.parse('{"title":"MPA Mode","description":"","frontmatter":{},"headers":[],"relativePath":"guide/mpa-mode.md","filePath":"en/guide/mpa-mode.md","lastUpdated":1719560776000}'),r={name:"guide/mpa-mode.md"},h={id:"mpa-mode",tabindex:"-1"};function k(c,e,E,g,m,u){const a=o("Badge");return d(),n("div",null,[s("h1",h,[e[0]||(e[0]=i("MPA Mode ")),l(a,{type:"warning",text:"experimental"}),e[1]||(e[1]=i()),e[2]||(e[2]=s("a",{class:"header-anchor",href:"#mpa-mode","aria-label":'Permalink to "MPA Mode
MPA (Multi-Page Application) mode can be enabled via the command line via vitepress build --mpa, or via config through the mpa: true option.
In MPA mode, all pages are rendered without any JavaScript included by default. As a result, the production site will likely have a better initial visit performance score from audit tools.
However, due to the absence of SPA navigation, cross-page links will lead to full page reloads. Post-load navigations in MPA mode will not feel as instant as in SPA mode.
Also note that no-JS-by-default means you are essentially using Vue purely as a server-side templating language. No event handlers will be attached in the browser, so there will be no interactivity. To load client-side JavaScript, you will need to use the special <script client> tag:
<script client>
document.querySelector('h1').addEventListener('click', () => {
console.log('client side JavaScript!')
})
</script>
# Hello<script client> is a VitePress-only feature, not a Vue feature. It works in both .md and .vue files, but only in MPA mode. Client scripts in all theme components will be bundled together, while client script for a specific page will be split for that page only.
Note that <script client> is not evaluated as Vue component code: it's processed as a plain JavaScript module. For this reason, MPA mode should only be used if your site requires absolutely minimal client-side interactivity.