Only deliver JS to certain users

I haven’t quite thought this one through yet, I might be overlooking something simple and obvious.

Is there a way to only deliver a JS files to certain users?
For example, I only want admin users to have access to an Admin object which contains a bunch of functions and calls. I’ve got that in a separate file in my client directory.

The reason isn’t for security (by obscurity) or anything - but rather, why would I want to send that JS asset to every client. It is something extra to download which has no value to that user.

The only thing I can think of would be to have the JS in the public directory - and the admin template that gets loaded can load that via a script element, but that seems pretty hacky.

This is a pretty popular feature request on the Meteor Roadmap. Go add your vote! :wink:

Using the public directory and doing it manually is the only solution I know of.

With the ability to add steps to the meteor asset pipeline and to dynamically load templates with Blaze, it seems like this could be solved by the community. If you’re interested in working on this perhaps you can put together a rough design and generate some momentum. A simple proof of concept would probably get a lot of people excited.

1 Like

I would love to contribute I just don’t even know where to start!

Packages are a mystery to me, but I am keen to learn. I will do some reading this long weekend - hopefully learn a thing or two!

edit: by the way, thanks for the trello link, I will vote it up!

The best way to start developing packages is to look at the source code of another package. maybe a very simple package. Believe me this will kick start your package development. Just clone the package and start making changes.

store the code in the database?