You’re pretty close!
What you can do is to register all of the scripts via the wp_enqueue_scripts
hook normally and then just enqueue them in the shortcode callback. This is telling WordPress about the scripts and then allowing you to only enqueue them as needed:
add_action( 'wp_enqueue_scripts' 'register_all_my_scripts' );
function register_all_my_scripts() {
wp_register_script( 'per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0' );
}
function this_is_my_shortcode(){
wp_enqueue_script('per-pas-belanja-online');
return '<div id="poppedout">Blah</div>';
}
add_shortcode('bubba', 'this_is_my_shortcode');
Hope it helps!