How to load external scripts

1

I'm adapting a theme (Bootstrap) with MeteorJS but the theme has more than 15 plugins (jQuery), I can not just put them in the /client folder and load all at the same time, some things (some in despair):

  • Put the scripts in the template footer with tag <script> , but were not loaded or when the template was reload , whether they lost or not carry

  • Using link the load is asynchronous, in this case not feasible, I'm loading dependent libraries between each other .

  • Using link I have the same problem of item 2, I even managed to make them depend on each other using callbacks however it is so horrendous that I refused to post the code.

  • EDIT

    When you first load the application several "Undefined is not a function" go to console , but when the reload is done, it works perfectly because library has already been loaded. I also used mrt:preloader but it did not work.

    What I need is to load a list of scripts in a synchronous order.

        
    asked by anonymous 12.11.2014 / 19:44

    2 answers

    1

    Well imagine that you do not want complicated things, knowing this the best way would be to PRODUCTION put all this sequentially into a single file and compress it with this Google tool

    link

    It's the best way to get performance

        
    15.11.2014 / 22:24
    0

    The way the Meteor loads the files is a headache. However, there are some directories with special meanings:

    client/compatibility -- Todos as bibliotecas que esperam ser globais, são carregadas primeiro
    

    One way to adjust this with dependencies, is within the client/compatibility folder, naming the files in numerical order. Meteor loads the files in lexicographic order.

    This would be horrendous and difficult to do, and subject to errors if lib changes the dependencies (it would involve you having to rename the files). So the way I recommend is to create packages .

    The Meteor packet system lets you explicitly specify dependencies between .js files.

    Link: link

    One way would be to create a package for each plugin. Map the dependencies between them and integrate them using the Meteor packet system. When done meteor deploy or meteor build , the packages will be minified in a single JS with the application.

    Another idea could be to map the most coupled dependencies and make them a single package. It's up to you, actually.

        
    16.04.2015 / 03:13