PrestaShop 9 errors
jquery-1.11.0.min.js 404 and "$ is not defined" after upgrading to PrestaShop 9
PrestaShop 9 keeps only jQuery 3.7.1 in js/jquery. Modules and themes that load an older file by its path get a 404, and every script that depends on it stops with "$ is not defined".
- The error
GET /js/jquery/jquery-1.11.0.min.js 404 (Not Found)- Removed in
- PrestaShop 9.0
- Usually found in
- Themes, older modules
What happened
PrestaShop used to ship several jQuery versions in js/jquery/, and some modules and themes loaded one of them by its exact file name. PrestaShop 9 keeps only jquery-3.7.1.min.js and jquery-migrate-3.4.0.min.js. Paths to jquery-1.11.0, jquery-3.4.1, jquery-3.5.1, jquery-migrate-1.2.1 or jquery-migrate-3.1.0 now return 404.
The 404 itself is harmless. The trouble starts after it: scripts that expected jQuery fail with $ is not defined or jQuery is not defined, and with them sliders, popups, product option pickers or back office forms.
The helper Media::getJqueryPath(), which some modules used to find the file, was already removed in PrestaShop 8.0.
The fix
Do not load jQuery yourself:
- Back office: PrestaShop 9 already loads jQuery 3.7.1 on every page. Remove the module's own
addJS()of an old file. - Front office: jQuery comes with the theme (Classic bundles it in its core JavaScript). Check what your theme provides before adding another copy, and never load a second jQuery on top of it: plugins attached to the first one disappear.
- Old plugins: code written for jQuery 1.x may use methods removed in 3.x, such as
.live(),.size()or.load(fn). The browser console shows which ones.jquery-migraterestores some of them for a while, but the real fix is to update the code.
// Before
$this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/jquery-1.11.0.min.js');
$this->context->controller->addJS(Media::getJqueryPath());
// After: nothing, jQuery is already on the page
Where else it hides
grep -rn "jquery-1\.\|jquery-3\.[45]\|jquery-migrate-\|getJqueryPath" modules/ themes/ override/
Look in the theme's head.tpl and layout templates too: hard-coded <script> tags are common there.