I'm trying to make a multi-page Meteor app (I'm using https://github.com/tmeasday/meteor-router). How do I conditionally load javascripts depending on the page content?
This is what I'm doing: the main page main.html has a {{renderPage}} within the <body> tag which is what the Meteor-router use. Say there is this page/template called home which is one of the pages and it has some of it's scripts. If it were not for Meteor some of these scripts are in <header> such as jquery, while others are at the end of <body>. I put a partial at the end of the home template called homeCustomScripts and it has a corresponding Template.homeCustomScripts function like so (I left-out many scripts, this is just an example):
Template.homeCustomScripts.created = function() {
scriptInsert = function () {
$('head').append('<script type="text/javascript" src="js-plugin/respond/respond.min.js">`
<script type="text/javascript" src="js-plugin/easing/jquery.easing.1.3.js"></script>`
<script type="text/javascript" src="js/custom.js"></script>');
}
}
Within main.html I have another partial called customScript and I have inside Template.customScript.rendered calls scriptInsert().
It should work, except that there are some really messy Javascript error at the Chrome console which I've no idea what it means:

I'm guessing that because Meteor also loads JQuery in <head> and I heard that Meteor is loading everything in there last, so maybe the JQuery plugin easing is loaded before that instance of JQuery.
But I don't know.
What's the best way to load different script for different page in a multi-page application in Meteor?