Writing a library that can be used by multiple programming languages

Since writing the same library in multiple languages is unpractical what would be the best way to write it once and make it available in different languages?

The library will be used on web and will not contain platform-specific code (will be able to run correctly on the client or the server). Also, it should not require from developers to use third party tools to load it. For example, in Javascript, it should be importable as an ES Module with import statement.

I already made some progress in Javascript, but realized that it would be better if the library can be used by more programing languages, hence I am considering writing the library in another language and, as I read somewhere, compile it to an interface for different languages. Is this even possible?