Q:

sub-URL~how to integrate javascript code

I found out that integrating code in root-URL and sub-URL is different.
script route: /vendor/assets/custom/js/scripts.js
Integrating javascript code in this way 
<script src="assets/js/scripts.js"></script> is only working for root-URL and not working for sub-URL.
root-URL: localhost:3000/
sub-URL:   localhost:3000/homepage/item
It was solved this way, 
<script src="../../assets/js/scripts.js"></script>
It's working for both root-URL and sub-URL.
But it's not perfect answer because
if sub-URL length is long, it's not appropriate.
Have to put more ../ to the code so it's not permanent.
Is there the permanent answer to this problem?
This way:
<script src="ABSOULTE_ADDRESS/assets/js/scripts.js"></script>

A:

You could prepend the path just with a slash, for example <script src="/assets/js/scripts.js"></script>, then it loads the file relative to the host name part of the URL.

