Custom javascript library to reuse in Button Card

HI,

I’d like to create a library of custom javascript functions to be reused in Button Card.
I created a common_functions.js file in /config/www.
I added a resource to lovelace for the created file. (/local/common_functions.js)
I created a simple example function in file common_functions.js:

function test_function(input) {
   var value = input + 1;
   return value;
}

I created an example card:

type: custom:button-card
name: |
   [[[
     return test_function(10);
   ]]]

But button-card doesn’t see my custom function.

ButtonCardJSTemplateError: ReferenceError: test_function is not defined in 'return test_function(10);'

Any tips?

I’m trying to do the same. Have you found a solution for this?

unfortunately not

And now ? because i’m looking to that too :wink: