Skip to Content
Menu
This question has been flagged
1 Reply
777 Views

Hello,

I am encountering an issue in Odoo 18 while working with JavaScript files for a website theme. Specifically, the plugins are throwing errors such as 'x' is not defined and similar issues.

Although jQuery (version 3.6.3) is included in the web module/package and is loaded by default in the web.assets_frontend bundle, the errors persist even when using plugins compatible with this version of jQuery.

NOTE : To clarify, I am using the plugins exactly as provided by the CDN, without any modifications to their code.

Here are the approaches I have tried in the web.assets_frontend bundle within the __manifest__.py file:

  1. Attempted to load the assets without explicitly including jQuery, as the required plugins are already compatible with version 3.6.3.
  2. Used a direct CDN link for jQuery.
  3. Provided a local path to jQuery in the asset declaration.


My primary goal is to implement animated snippets on the website. However, despite trying the above approaches, I have been unable to resolve the issue.

I would greatly appreciate any insights or solutions to overcome this challenge.

Avatar
Discard
Best Answer

Hello Mohammed Salman Uddin,


I hope you are doing well.


To resolve the issue, I recommend the following approach:

- Import loadJS from Odoo's core assets in the JavaScript file where you wish to implement the feature:

import { loadJS } from "@web/core/assets";

- Then, use loadJS(url) to load the JavaScript file from the URL:

loadJS(url);


- This method helps avoid any potential jQuery issues and prevents script conflicts.

- It ensures a smooth and efficient loading process for external JavaScript files in Odoo.

- Make sure to check the compatibility of the external JavaScript with your Odoo version.


I Hope this information proves helpful to you.


Thanks & Regards,

Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
0
Nov 24
956
1
Jun 25
418
1
May 25
539
2
Apr 25
650
0
Apr 25
608