In Meteor JS, how to control Javascript load order in relation to DOM load order? For animations

后端 未结 5 570
孤独总比滥情好
孤独总比滥情好 2021-01-03 07:48

I\'ve got a template that I downloaded:

http://halibegic.com/projects/merlin/

I want to use it in Meteor and I\'m having major issues with

&         


        
5条回答
  •  隐瞒了意图╮
    2021-01-03 08:14

    Thanks to imslavko for the answer!

    http://docs.meteor.com/#meteor_startup

    On a server, the function will run as soon as the server process is finished starting. On a client, the function will run as soon as the DOM is ready.

    So I put this into my client/views/application/layout.js. It uses the jQuery $.getScript, so you have to make sure that jQuery is loaded before you try this:

    Meteor.startup( function () {
      $.getScript("assets/js/jquery.min.js");
      $.getScript("assets/js/bootstrap.min.js");
      $.getScript("assets/js/isotope.pkgd.min.js");
      $.getScript("assets/js/imagesloaded.min.js");
      $.getScript("assets/js/jquery.scrollTo.min.js");
      $.getScript("assets/js/jquery.nav.min.js");
      $.getScript("assets/js/jquery.appear.min.js");
      $.getScript("assets/js/twitterFetcher.min.js");
      $.getScript("assets/js/script.js");
    });
    

    So all of these files will now load AFTER the DOM loads, and therefore animations work.

提交回复
热议问题