Diogenes
Diogenes

Reputation: 2757

How can I conditionally send templates and javascript files to the client in meteor?

This is related to a previous question I asked about conditionally sending document data to the client in meteor.

Lets say I have a parse-like data editor/browser available for user accounts marked as system admin, as well as some pages that show logging information about the app. I'm using meteor-router and a filter to accomplish this.

99% of users won't need to to see those interfaces, but the (massive amounts of) javascript for them is still sent to the client. The admin specific javascript and templates are separated into their own files, how can I make sure they are not sent to the client unnecessarily (when the logged in user is not an admin)?

Is the best option really to split the admin interface into a separate app and point it at the original's mongo?

Upvotes: 3

Views: 474

Answers (2)

Dan Dascalescu
Dan Dascalescu

Reputation: 152085

At the moment (June 2015), incremental template loading is still on the Meteor Roadmap.

The best solution might actually be to split away the admin app, also for security reasons.

If you do want to keep everything in one app, the leading community package for lazy loading is numtel:lazy-bundles.

Upvotes: 0

Rahul
Rahul

Reputation: 12231

If you don't want Meteor to load your client-side scripts automatically, you could place them in the /public directory and load them yourself when you need them.

However, in the case of an admin environment, it may actually be better from a software development perspective to separate all of that into its own app, pointing to the same database like you said.

Upvotes: 2

Related Questions