Javascript_include once

What’s the best way to include a javascript from a partial - but make
sure that it is only included once?

I tried doing this with ‘set’ and helpers, but they seem to get
processed after the layout is called.