- 上传者: Administrator
- 上传时间:2024年02月24日 05时32分32秒
Managing static assets in Odoo is more complicated. As you know, it has extensive applications and a code base. Odoo's different apps have specific pu ......
Managing static assets in Odoo is more complicated. As you know, it has extensive applications and a code base. Odoo's different apps have specific purposes and different user interactions. So Odoo's assets are not as simple as other applications. For example, web clients, websites, POS, or mobile apps have different requirements. Additionally, some elements can be large but are rarely necessary. In this case, you should lazy load (if necessary). Loading large unneeded static assets is unhealthy and may need to be loaded as needed. To avoid this example in Odoo, let's use different asset batches for each codebase.
Managing Static Assets
Modern websites contain a large number of JavaScript and CSS files. These static files send requests to the server when the page is uploaded to the browser. A large number of requests slows down the website. Many websites combine multiple files to serve static assets to avoid this problem. There are many tools for managing these types of items, but Odoo has its way of managing static assets.
Asset types
In Odoo, There are three different types of assets that are script (JavaScript files), style (CSS or SCSS files), and templates (XML files).
1. Script (JavaScript files)
Odoo supports three types of JavaScript files, each bundled and served to the browser. The different types of JavaScript files supported by Odoo are plain JavaScript files, native JavaScript modules, and Odoo modules. During this simple JavaScript, the file is only reserved for external libraries and is also used for certain forms of low-level purposes. All newly created JavaScript files must be built within the native JavaScript module system. Odoo modules are a custom module system for these JavaScript files, processed and minified when not in asset debug mode, and finally concatenated together. Finally, the result is saved as an attachment. These attachments are typically loaded into static files using the <script> tag.
2. Style (CSS or SCSS files)
Styling can be done in CSS or SCSS files. Style files are minified and merged after being treated like JavaScript files. (debug mode unless debug=asset mode). SCSS files are converted to CSS. The file is then saved as an attachment and loaded with the <link> tag.
3. Templates (XML files)
A template is a static XML file. They are called to be read-only as soon as they are needed and are eventually concatenated in small amounts, much like JavaScript and Elegance files. Every time the browser loads her Odoo, it calls /web/WebClient/qweb/controller to get the template. QWeb is the first template engine used by Odoo. This is an XML templating engine, primarily used for pushing HTML fragments and pages. Template directives are defined as t-prefixed XML attributes. Conditional t-ifs that render components and other attributes directly.
Note that in most cases, browsers only make requests when the page is first loaded. This is because each of these assets is linked to a checklist included in the page's source. Then add a checksum to the URL. This allows you to safely set cache headers over time.
本文章从网上收集,如有侵权请联系tderp@tderp.com删除- 微信扫一扫,一分也是爱:
服务原则及地区范围
宜兴通达网络科技有限公司,地处中国宜兴环科园内,是一家高新技术企业。公司在企业网络维护和企业信息化建设与咨询方面,有10多年经验。
我公司愿与客户一道,力求彻底解决客户问题!
我们不是在给企业提供“头痛医头、脚痛医脚”的暂时解决方案,而是在部署根本性安全与稳定服务!!
我们愿携手客户,建立企业IT规划;杜绝随意安装系统、软件等操作;力求共同维护有序、安全、稳定的网络办公环境!!!
IT服务,服务是根本,客户是上帝;我们提供快速响应、快速上门、快速排查,提供优质高效的服务!!!!
通达科技提供全国范围内的服务,服务形式包括远程协助、电话咨询、电子邮件咨询、传真咨询、问答平台的问题解决等。
宜兴地区提供上门服务:
- 市区服务:宜城街道、城北街道(屺亭街道)、新街街道、新庄街道、环科园、渚桥开发区
- 市郊服务:张渚镇、西渚镇、太华镇、徐舍镇、官林镇、杨巷镇、新建镇、和桥镇、高塍镇、万石镇、周铁镇、芳桥镇、丁蜀镇、湖父镇。