angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

Long application load #3597

Closed milosz-pawlicki closed 4 years ago

milosz-pawlicki commented 6 years ago

This issue tracker is for Bug Reports and Feature Requests only.

Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a (check one box):

My version of UI-Router is: (type version) 1.0.11

Bug Report

Current Behavior:

On application start when we register about 2700 routs it takes about 30seconds. Previously because we had angular 1.4.9 we were using ui router in version 0.3.1 where registering routes was very fast (1-2 seconds). Can you explain why stateRegistry.register takes that long? is it a bug or we should use another way to register routes? Please answer as quickly as possible because we have deadline with production release and we need to fix it quickly

Expected Behavior:

faster registering routes

Link to Plunker or stackblitz that reproduces the issue:

( if you want a response to your issue, provide a way to reproduce it ) ( http://bit.ly/UIR-Plunk1 ) ( https://stackblitz.com/edit/ui-router-angularjs )

Feature Request

(type feature request here)

General Query

Please direct general implementation questions to StackOverflow: http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router

Please review the Sample Application which highlights common approaches: https://github.com/ui-router/sample-app-angularjs

(type general query here)

tsvetan-ganev commented 6 years ago

Why are you trying to load 2700 routes at application startup? Have you tried lazy loading your routes definitions?

In our application we also have hundreds of routes, but we register them dynamically once the user visits a feature module.

Example:

$stateProvider.state("orders.**", {
      url: '/orders',
      lazyLoad: lazyLoad('OrdersModule') // function which loads an AngularJS module by name
});

This will register only top-level feature routes on application start, but the modules' routes will be registered once the user actually visits the orders/** pages. In our case each module has it's own route definitions inside.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.