How should I include other javascript?

21 views
Skip to first unread message

Matthew Page

unread,
Feb 9, 2012, 1:52:37 PM2/9/12
to Toura Mulberry
I want to include some 3rd party javascript in my app.

I could drop the include into my template, but I am not sure if that
is the correct place to put it.
Also, where should I put the js file itself? Root of javascript
folder?

Thanks!

Rebecca Murphey

unread,
Feb 9, 2012, 2:02:04 PM2/9/12
to toura-m...@googlegroups.com
Presently, these are the steps for adding vendor JS to your app:

1. Add the file to your app's javascript directory. Note that the file should be named so there is only one '.' in it, e.g. MyVendorCode.js

2. Open the file you just added, and add a dojo.provide statement at the beginning. For example:

dojo.provide('client.MyVendorCode');

3. Open your app's javascript/base.js and add the following somewhere after the dojo.provide statement:

dojo.require('client.MyVendorCode');

The vendor code will now be available in your app, and will automatically be included in the "built" JavaScript that is generated for device testing and production.
--
Rebecca Murphey
Lead JavaScript Developer at Toura

Mulberry: http://mulberry.toura.com | Toura: http://toura.com
You should follow @touradev on Twitter

Matthew Page

unread,
Feb 9, 2012, 2:39:03 PM2/9/12
to Toura Mulberry
I should have asked this upfront as well:

How do I include CSS that comes with the third party javascript?

I read the http://mulberry.toura.com/docs/styles-and-theming.html doc.
I suppose I could import the scripts into base.scss.


On Feb 9, 11:02 am, Rebecca Murphey <rmurp...@toura.com> wrote:
> Presently, these are the steps for adding vendor JS to your app:
>
> 1. Add the file to your app's javascript directory. Note that the file
> should be named so there is only one '.' in it, e.g. MyVendorCode.js
>
> 2. Open the file you just added, and add a dojo.provide statement at the
> beginning. For example:
>
> dojo.provide('client.MyVendorCode');
>
> 3. Open your app's javascript/base.js and add the following somewhere after
> the dojo.provide statement:
>
> dojo.require('client.MyVendorCode');
>
> The vendor code will now be available in your app, and will automatically
> be included in the "built" JavaScript that is generated for device testing
> and production.
>

Daniel Imal

unread,
Feb 9, 2012, 3:15:05 PM2/9/12
to toura-m...@googlegroups.com
Yes, at the moment, base.scss is the the only place to import that css. The path will be a little awkward:

@import '../../javascript/<path to vendor css>';

But it should work. Let me know if you have any issues with this.
Reply all
Reply to author
Forward
0 new messages