Call function from a js external file


I have a code in a external file and my objective is call it from API/CODE Knack console.

My file is called new_optimization.js and start in this mode..

function new_optimization(fecha, centroid, idoptimization){
var fecha = fecha;
var centroid = centroid;
var idoptimizacion = idoptimization;
var orders = [];....

In the API/CODE Knack console I'm using the next code.

LazyLoad.js([''], function () {

$(document).on('knack-form-submit.view_1670', function(event, view, record){

$(document).ready(function() {
var fecha = record.field_1498_raw.date_formatted;
var centroid = record.field_1499_raw[0].id;
var idoptimizacion =;
var optimiza = new_optimization(fecha, centroid, idoptimizacion);

The error I get is the new_optimization is not defined, I have tried some variants but the error is always the same.

Anybody can help me please?

Best Regards,