bshiluk / vue-wordpress

Use Vue.js and the WP REST API to build WordPress themes as SPAs with dynamic routing, HMR for development, SEO enabled, and SSR capable. Demo:
http://vue-wordpress-demo.bshiluk.com
491 stars 112 forks source link

Lazy Load Routes #8

Open sethharris4989 opened 5 years ago

sethharris4989 commented 5 years ago

This may be outside of the scope of the project, but can you give any insights or advice on getting code splitting/lazy loading routes to this theme?

Bundle sizes can get out of control, so having this would put this theme over the top of anything else I've found.

Thanks!

schuhwerk commented 4 years ago

Just came across this post by accident. I had the same problem/question. Lazy loading routes is probably not a good idea, because it delays the time until you first see posts. So I added a global variable (in another theme) with wp-localize script and translated them from php to vue-router. You could probably prepare all routes in PHP and use that to initialize your Router (in JS).