Third party Front-End JS file to import

Hi,

I am quite new to meteor and I try to import some front-end JS files made for the bootstrap template that I use.

I have a JS file containing all the functions used for the front-end. it looks like this :

function(window, document, $) {
    'use strict';
    var $html = $('html');
    $body = $('body');

    $(window).on('load',function(){
        $('a[data-action="collapse"]').on('click',function(e){
            e.preventDefault();
            alert('test');
            [...]
        });
        [...]
    });

    $('.nav-link-expand').on('click', function(e) {
        alert('expand');
    });
    [...]

})(window, document, jQuery);

I tried to put the file in client/compatibility but no luck. Same with client/lib: the file is loaded once but the functions are not called when I click on a button for example.

I only managed to load the script using $.getScript(’./theme-app.js’);
But the window.onLoad part is not working. And the path is changing so the file doesn’t load all the time (for example if my route is not at the root like /index but like /profile/modify).

Anyone could help me on the proper way to import those JS files into my project ?
I would really appreciate your help :slight_smile:

Hi again, anyone with a good idea on that ?

try wrapping anything that depends on load in this