custom javascript in shopify code example

Example 1: how to add jquery to shopify

<!-- Include jQuery in your theme.liquid file, between <head> tag  -->
  
  <head>
    <script
    src="https://code.jquery.com/jquery-3.4.1.js"
    integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
    crossorigin="anonymous">
  	</script>  
  </head>

Example 2: custom js shopify

If I understand correctly, the asset_url filter is what you are looking for.

To include a JS file in a .liquid file, you use:

{{ 'script.js' | asset_url | script_tag }}

And a CSS file:

{{ 'style.css' | asset_url | stylesheet_tag }}