All Projects → egoist → Vue Router Prefetch

egoist / Vue Router Prefetch

Licence: mit
Prefetch links when they are visible in viewport.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Router Prefetch

Vuejs Firebase Shopping Cart
Shopping cart demo using Vuejs and Firebase
Stars: ✭ 274 (-13.02%)
Mutual labels:  vue-router
Myblog
vue + node 实现的一个博客系统
Stars: ✭ 285 (-9.52%)
Mutual labels:  vue-router
Vue Project
基于vue-cli构建的财务后台管理系统(vue2+vuex+axios+vue-router+element-ui+echarts+websocket+vue-i18n)
Stars: ✭ 301 (-4.44%)
Mutual labels:  vue-router
Mui Vue2
mui+mint+vue2.x+vue-router+vuex+webpack最终打包成原生apk的app项目,样式使用vue移动端mint ui框架,原生手机能力偏重于mui框架,欢迎star!
Stars: ✭ 278 (-11.75%)
Mutual labels:  vue-router
Shkjem
基于Vue&ElementUI的企业官网
Stars: ✭ 281 (-10.79%)
Mutual labels:  vue-router
Space Snake
A Desktop game built with Electron and Vue.js.
Stars: ✭ 289 (-8.25%)
Mutual labels:  vue-router
Vue Koa2 Login
基于 token 的登录注册。
Stars: ✭ 275 (-12.7%)
Mutual labels:  vue-router
Vue Kindergarten
Modular security for Vue, Vuex, Vue-Router and Nuxt
Stars: ✭ 303 (-3.81%)
Mutual labels:  vue-router
Vue Zhihu Daily
🤓使用vue编写的练手的知乎日报WebApp(iOS版)
Stars: ✭ 285 (-9.52%)
Mutual labels:  vue-router
Roastandbrew
Updated content available! We learned a lot since we originally wrote this article. We now have this updated for Laravel 8, Vue, and NuxtJS 👉 https://srvrsi.de/book
Stars: ✭ 300 (-4.76%)
Mutual labels:  vue-router
Vue Smart Route
Smart route search to make intelligent looking apps with Vue.js.
Stars: ✭ 280 (-11.11%)
Mutual labels:  vue-router
Plato
❤️ a Boilerplate for [mobile] SPAs use vue, vuex, vue-router
Stars: ✭ 283 (-10.16%)
Mutual labels:  vue-router
Vue Vben Admin
A modern vue admin. It is based on Vue3, vite and TypeScript. It's fast!
Stars: ✭ 8,036 (+2451.11%)
Mutual labels:  vue-router
Laravel Vue
运用laravel5.4 + vue2.0 + elementui
Stars: ✭ 276 (-12.38%)
Mutual labels:  vue-router
Vue News
Vue2.5知乎日报单页应用
Stars: ✭ 300 (-4.76%)
Mutual labels:  vue-router
Vue.news
项目地址
Stars: ✭ 275 (-12.7%)
Mutual labels:  vue-router
Vue Testing Examples
Advanced testing with vuejs. When you need to go beyond Getting started section and see some real world example with everything that proper tests should have.
Stars: ✭ 288 (-8.57%)
Mutual labels:  vue-router
Nuxt Elm
基于nuxt2+vue构建的全栈开源项目
Stars: ✭ 304 (-3.49%)
Mutual labels:  vue-router
Pageainimate
vue实现webapp页面切换动画
Stars: ✭ 301 (-4.44%)
Mutual labels:  vue-router
Vue Cnodejs
基于vue.js重写Cnodejs.org社区的webapp
Stars: ✭ 3,065 (+873.02%)
Mutual labels:  vue-router

vue-router-prefetch

NPM version NPM downloads CircleCI

Please consider donating to this project's author, EGOIST, to show your ❤️ and support.

Features

  • Prefetch links when they are visible in viewport.
  • You don't need to change your code base to make it work.
  • Tiny-size.

Install

yarn add vue-router-prefetch

Usage

You need to use this plugin after vue-router:

import Vue from 'vue'
import Router from 'vue-router'
import RouterPrefetch from 'vue-router-prefetch'

Vue.use(Router)
Vue.use(RouterPrefetch)

Then you can use <router-link> without any changes, when this component is visible in viewport, it will automatically prefetch the (async) route component.

Check out the live demo.

You can also register it as a new component instead of overriding <router-link>:

Vue.use(RouterPrefetch, {
  componentName: 'QuickLink'
})

Now you can use it as <quick-link> in your app.

Browser Support

  • Without polyfills: Chrome, Firefox, Edge, Opera, Android Browser, Samsung Internet.
  • With Intersection Observer polyfill ~6KB gzipped/minified: Safari, IE11

Props

All props of <router-link> are still available, additional props are listed below.

prefetch

  • Type: boolean
  • Default: true

Whether to prefetch the matched route component.

You can also set meta.prefetch on vue-router's route object to disable prefetching this route for all <router-link>s:

new VueRouter({
  routes: [
    {
      path: '/some-async-page',
      meta: { prefetch: false },
      component: () => import('./async-page.vue')
    }
  ]
})

It's also possible to turn of prefetching globally:

Vue.use(RouterPrefetch, {
  prefetch: false
})

prefetchFiles

  • Type: string[]
  • Examples: ['/foo.css']

A list of additional files to prefetch. By default we only prefetch the route component.

You can also set meta.prefetchFiles on vue-router's route object, it will be merged with the prop value:

new VueRouter({
  routes: [
    {
      path: '/some-async-page',
      meta: { prefetchFiles: ['/foo.css'] },
      component: () => import('./async-page.vue')
    }
  ]
})

timeout

  • Type: number
  • Default: 2000 (ms)

Timeout after which prefetching will occur.

Credits

Inspired by quicklink and nuxt-link.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-router-prefetch © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).

Website · GitHub @EGOIST · Twitter @_egoistlily

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].