Where is the correct place to add and include the js file from a theme?


#1

Hi,

According to meteor app structure,
where is the correct place to add and include the js file from a theme?


That file should be global.

Thanks,


#2

For global js and jquery plugins you should put it in the folder:

client/compatibility/

From the guide:

This folder is for compatibility with JavaScript libraries that rely on variables declared with var at the top level being exported as globals. Files in this directory are executed without being wrapped in a new variable scope. These files are executed before other client-side JavaScript files.

It is recommended to use npm for 3rd party JavaScript libraries and use import to control when files are loaded.


#3

Just to add to @coagmano’s reply:

Even though you’ve added the library in the right place, with the correct dependencies, doesn’t mean it will work. Reactive applications don’t always have the DOM in the expected state for lots of these jQuery-based theme libraries.


#4

I am using Blaze and I like it.
It looks it is easier to migrate a template to blaze than to angular or react.

Why people insist in using meteor with angular or react?


#5

I was including Blaze in my comment. Converting the HTML and CSS is straightforward. The issues, when they arise, are with integrating jQuery functionailty. Most often that relies on the DOM being fully constructed (think WordPress) before jQuery functionality is invoked. That’s commonly not the case with modern, reactive, front-end libraries (Blaze, React, Vue etc).


#6

There are also some packages you can check out at AtmosphereJS.