I personally hate adding JS this way. Could you think of the way which would execute the below function in a more "natural" and "organic" way ?