I am trying to make a multi-page Meteor application (I am using https://github.com/tmeasday/meteor-router ). How can I conditionally load javascripts depending on the content of the page?
This is what I am doing: the main page main.htmlhas {{renderPage}} in the tag <body>used by the Meteor router. Let's say that this page / template is called home, which is one of the pages and has some of its scripts. If not for the Meteor, some of these scripts are in <header>, such as jquery, while others are at the end <body>. I put a partial at the end of the template homecalled homeCustomScriptsand it has the corresponding Template.homeCustomScripts function (so I left a lot of 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>');
}
}
Inside main.html, I have another partial customScript call, and I have inside Template.customScript.renderedcalls scriptInsert().
, , Chrome - Javascript, , :

, , Meteor JQuery <head>, , Meteor , , , , JQuery- JQuery.
.
script Meteor?