How to use liquid template tags in external javascript in jekyllrb?

I’m trying to remove all the inline scripts from our jekyllrb project. The inline scripts pull some values from jekyll data eg. {{site.homepage_title}}, which throws an error when moved to an external/standalone javascript file.

I try renaming the javascript file for example search.js to search.js.liquid but it doesn’t work.

Any ideas or workaround would be much appreciated. Thanks!