Book Image

Getting Started with Meteor.js JavaScript Framework

By : Isaac Strack
Book Image

Getting Started with Meteor.js JavaScript Framework

By: Isaac Strack

Overview of this book

Table of Contents (14 chapters)

The client and server folders


Up to this point, we've put all of our JavaScript code in one file: LendLib.js.

Inside LendLib.js, we have two sections that are separated by if statements. The client-facing code is found inside the if (Meteor.isClient) {...} block, and the server-side code is found inside the if (Meteor.isServer) {...} block.

This structure works fine for a very simple application, but when we are writing a more complex application, or we have multiple people working on the same app, trying to share one file with conditional statements will quickly turn into a nightmare situation.

Additionally, Meteor will read any and all files in our application folders and try to apply JavaScript to both the client and the server. This makes for a sort of strange situation if we want to use a client-facing JavaScript library (for example, Twitter Bootstrap or jQuery). If we add the library to the root folder, Meteor will try to implement that file on both the client and the server. This either...