The simplest way is to add the js file to the Blazor project like you said. For a slightly more maintanable solution, consider creating a Razor class library ("RCL") instead of a .Net class library, as it supports referencing static assets (see this article and more specifically here for instructions).
There is also the much more complicated way of "streaming" your js file from the resource file of your .Net Library. The advantage is that a normal .Net standard class library will do, and you don't need to reference the script with a script tag. You can implement this by referencing your js file as an embedded resource like this (in the .csproj of your .Net class library):
<ItemGroup>
<EmbeddedResource Include="wwwroot\script\MyJs.js"
LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
and then invoke js with the contents of your file using eval:
// Get contents of resource
string scriptContent;
using (var stream = this.GetType().Assembly.GetManifestResourceStream("blazor:js:MyJs.js"))
{
using (var sr = new StreamReader(stream))
{
scriptContent = await sr.ReadToEndAsync();
}
}
JSRuntime.InvokeAsync<T>("eval", scriptContent)
Full-fledged example of the last strategy here (and here) (Disclaimer: I'm the maintainer).
Razor Class Libraryin Visual Studio. It will create a sample project with an example of JavaScript interop using an included javascript file.