Odoo Help


Java script JQUERY in website: ReferenceError: $ is not defined

Ralph LAvaud
on 4/30/15, 2:15 PM 6,514 views

Hello, I am trying to write some JQUERY code in a .js file. No matter how is write the code I get a

ReferenceError: $ is not defined

I know this is related to jquery and I looked at other .js file and they seem to reference $ just fine. What I am missing? Even this errors out

(function () { 

$(document).ready(function() {




Shawn Varghese

--Shawn Varghese--
| 5 3 7
Dubai, United Arab Emirates
--Shawn Varghese--

Shawn Varghese
On 4/30/15, 4:01 PM

Do you need the () at the end?


(function () {
 $(document).ready(function() {


Shawn this seems to work but I think my problem goes deeper. My code requires jquery so I need to put it at the bottom after all the other JavaScript files, would you you know how to do that?

Ralph LAvaud
on 4/30/15, 6:51 PM

If I understood your question correctly, I think Nedas's answer below would address it. If you could let us know more specifically what you need, we could explain better with code snippets.

ePillars Systems LLC, Shawn Varghese
on 5/2/15, 4:19 AM
Nedas Zilinskas
On 5/1/15, 7:54 AM

Hi Ralph,

This might mean that you include your file before the jQuery is loaded.

To make sure you include your file after jQuery library you would need to extend either "website.assets_frontend" or "website.assets_backend" depending where you use it.

See example inheritance of "website.assets_frontend" template below.

<template id="assets_frontend" inherit_id="website.assets_frontend">
    <xpath expr="." position="inside">
        <script type="text/javascript" src="/module_name/static/src/js/filename.js"/>

The code above extends "website.assets_frontend" and includes new JS file to the bottom (position="inside") of the list meaning all other JS files will be loaded before this.

I am also facing the same error on loading my template. I have added my JS file in the 'assets_frontend' like you said, but it didn't resolve the problem.

Gopakumar N G
on 5/30/16, 8:02 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/30/15, 2:15 PM
Seen: 6514 times
Last updated: 6/18/15, 4:04 AM