Open Javiani opened 7 years ago
Hi,
thanks for your interest in vanilla-ui-router and for your feature request :) Sounds very interesting. I plan a "middleware" feature (similar to that of redux or expressjs) which is registered once while creating the router-object and is called immediately before any route-handler is invoked. Then it's possible to write a lazy-loading middleware or any other "plugins". I like the middleware concept because it keeps the router-core very simple and small and you can achieve complex additions which are completely encapsulated from the rest.
What do you think about that?
I hope I'll find some time in the near future, implementing the middleware feature. Then we could test the lazy loading as a middleware. If you are interested, pull requests are very welcome :)
René
What do you think about that?
Perfect!
I hope I'll find some time in the near future, implementing the middleware feature. Then we could test the lazy loading as a middleware. If you are interested, pull requests are very welcome :)
Sure! I am not sure if I can write some poc because I'm already committed to another project, but I can certainly help with fixes and tests.
I can share my solution so maybe it can be useful somehow.
My abstraction that loads html, css, js : https://github.com/jails-org/Demos/blob/master/TodoSPA/front/modules/loader/index.js
The use-case can be found here: https://github.com/jails-org/Demos/blob/master/TodoSPA/front/apps/application/index.js#L42
The third-party router calls my loader
on every url changes, the loader will get all assets and cache them, it will always load them only once.
Thank you for your attention, I'm hoping for more vanilla js contribution from front-end community just like this one.
o/
Hi!
Very nice project... I was looking for something just like this. But, it would be very nice if it could also load assets like embedded js and css in the template files.
One of the most concerns regarding SPA's is about performance. So, is better to load js and css bundles progressively. Having all css and js already in the first page load can be a huge performance issue. It's always nice to get just the assets for that page you're visiting...
It's really difficult to find some router that does that, I can achieve that using a combination with some router library and a module that loads html,css,js that I had to write on my own, but it has jQuery's dependency.
If your router could do such thing it would be perfect...
Great project! Keep it up!