<p>You would use <a href="https://developer.mozilla.org/en/docs/Web/HTML/Element/script" rel="noreferrer"><code>&lt;script&gt;</code></a> tags in your template, preferable in a _layout.html or _base.html template which you <a href="http://twig.sensiolabs.org/doc/tags/extends.html" rel="noreferrer"><code>extend</code></a> from all your other templates. </p>

CC BY-SA 3.0
2016-02-17T11:26:16.953Z
Thanks for your reply. I had a look at the source code of Craft. It looks like that Craft uses jquery and jquery UI, so I am thinking maybe we can use the jquery and jquery UI bundled in the default installation of Craft, but I am not sure if this is true and if this is true, how can I use the bundled jquery and jquery UI.
pumpum
CC BY-SA 3.0
2016-02-17T11:36:05.783Z
No, it's just in the package for the control panel and there's no easy or recommended way to use it for your front end templates.
carlcs
CC BY-SA 3.0
2016-02-17T12:01:26.003Z
There's really no good reason to use the bundled version of jQuery and jQuery UI – you're better off including your own, local files in the public root folder, or use a CDN. Also, you might find the [`{% includeJsFile %}`](https://craftcms.com/docs/templating/includejsfile) tag useful.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-02-17T21:47:42.053Z
Yeh I wouldn't use any CMS built-in front end files. You're now at the mercy of when Craft updates, you need to make sure your own front end code doesn't break in some weird way. There's rarely a security vulnerability with something like jquery that keeping an old version would put your site at risk. If you're used to something like WordPress, where the best practice IS to use that ancient version it comes with, consider this is a feature not a bug...
RitterKnight
CC BY-SA 3.0
2016-02-17T21:56:20.320Z
@MatsMikkelRummelhoff and RitterKnight, thanks for contributing and making this answer actually helpful, now that we know what the OP was after.
carlcs
CC BY-SA 3.0
2016-02-18T06:16:57.950Z
Hi @MatsMikkelRummelhoff and RitterKnight, I really appreciate your explanation :)
pumpum
CC BY-SA 3.0
2016-02-17T10:53:06.160Z
2016-02-17T10:53:06.160Z
carlcs
<p>This is one (of the many) great things about Craft. You can literally include any javascript library however you like. In general, if there is a library you want to use, you can simply follow the guide for that particular library.</p>

<p>A traditional approach is to include jQuery in the <code>&lt;head&gt;</code> of your document, then any other scripts after.</p>

<p>I personally use <a href="http://requirejs.org/" rel="nofollow">requirejs</a> for my projects. To do that, I follow the guide on the requriejs website. Generally, I'll do this on a <code>_layout.html</code> file that way it is included across all pages of my application.</p>

<p>Because Craft doesn't force you to follow any tempting rules, you are free to use whatever-however you like.</p>

CC BY-SA 3.0
2016-02-17T13:00:30.400Z
2016-02-17T14:25:31.407Z
2016-02-17T14:25:31.407Z
Damon
<p>I am wondering what is the correct way to include jQuery and jQuery UI in Craft?</p>

<p>Thank you.</p>

<jquery>
What is the correct way to include jQuery and jQuery UI in Craft?
# What is the correct way to include jQuery and jQuery UI in Craft?

(Asked by: username_0 on 2016-02-17)

I am wondering what is the correct way to include jQuery and jQuery UI in Craft?

Thank you.

**Tags:** jquery


---

## 2 answers

### Answer by username_1 on 2016-02-17. Score: 5

You would use

> **Comments:**
> **username_0**: Thanks for your reply. I had a look at the source code of Craft. It looks like that Craft uses jquery and jquery UI, so I am thinking maybe we can use the jquery and jquery UI bundled in the default installation of Craft, but I am not sure if this is true and if this is true, how can I use the bundled jquery and jquery UI.  
> **username_1**: No, it's just in the package for the control panel and there's no easy or recommended way to use it for your front end templates.  
> **username_2**: There's really no good reason to use the bundled version of jQuery and jQuery UI – you're better off including your own, local files in the public root folder, or use a CDN. Also, you might find the [`{% includeJsFile %}`](https://craftcms.com/docs/templating/includejsfile) tag useful.  
> **username_3**: Yeh I wouldn't use any CMS built-in front end files. You're now at the mercy of when Craft updates, you need to make sure your own front end code doesn't break in some weird way. There's rarely a security vulnerability with something like jquery that keeping an old version would put your site at risk. If you're used to something like WordPress, where the best practice IS to use that ancient version it comes with, consider this is a feature not a bug...  
> **username_1**: @MatsMikkelRummelhoff and username_3, thanks for contributing and making this answer actually helpful, now that we know what the OP was after.  
> **username_0**: Hi @MatsMikkelRummelhoff and username_3, I really appreciate your explanation :)  

---

### Answer by username_4 on 2016-02-17. Score: 5

This is one (of the many) great things about Craft. You can literally include any javascript library however you like. In general, if there is a library you want to use, you can simply follow the guide for that particular library.

A traditional approach is to include jQuery in the  of your document, then any other scripts after.

I personally use [requirejs](http://requirejs.org/) for my projects. To do that, I follow the guide on the requriejs website. Generally, I'll do this on a `_layout.html` file that way it is included across all pages of my application.

Because Craft doesn't force you to follow any tempting rules, you are free to use whatever-however you like.


---

