Call a javascript function from another file in a chrome extension

Viewed 442

I'm trying to build a chrome plugin that analyzes the URL and runs some functions depending on it. The js file is like of the format

function fn1(){
    //some logic
}

function fn2(){
    //some logic
}

if (url == 'site1'){
    fn1();

} else if (url == 'site2'){
    fn2();

}

Now the problem is, fn1 and fn2 are fairly large and for readability, I'd like to move them to another file and import them. I have tried

import {fn1} from './file.js';

This gives an error

cannot use import outside of a module

Any other ideas on how to do this? Thanks

0 Answers
Related