[jquery] $.widget is not a function

I want to make use of some dragable elements.. but as soon as I load the page I get this

$.widget is not a function

the code

<script src="js/jquery/jquery-1.6.js" type="text/javascript"></script>

<script src="js/jquery/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="js/jquery/jquery.ui.widget.js" type="text/javascript"></script>

This question is related to jquery

The answer is


Place your widget.js after core.js, but before any other jquery that calls the widget.js file. (Example: draggable.js) Precedence (order) matters in what javascript/jquery can 'see'. Always position helper code before the code that uses the helper code.


Maybe placing the jquery.ui.widget.js as second after jquery.ui.core.js.


May be include Jquery Widget first, then Draggable? I guess that will solve the problem.....


I got this error recently by introducing an old plugin to wordpress. It loaded an older version of jquery, which happened to be placed before the jquery mouse file. There was no jquery widget file loaded with the second version, which caused the error.

No error for using the extra jquery library -- that's a problem especially if a silent fail might have happened, causing a not so silent fail later on.

A potential way around it for wordpress might be to be explicit about the dependencies that way the jquery mouse would follow the widget which would follow the correct core leaving the other jquery to be loaded afterwards. Still might cause a production error later if you don't catch that and change the default function for jquery for the second version in all the files associated with it.