diff --git a/addons/web/static/src/legacy/js/public/lazyloader.js b/addons/web/static/src/legacy/js/public/lazyloader.js index e4c98b2ec38..5182d92bd30 100644 --- a/addons/web/static/src/legacy/js/public/lazyloader.js +++ b/addons/web/static/src/legacy/js/public/lazyloader.js @@ -103,6 +103,7 @@ function _loadScripts(scripts, index) { } var script = scripts[index]; script.addEventListener('load', _loadScripts.bind(this, scripts, index + 1)); + script.setAttribute('defer', 'defer'); script.src = script.dataset.src; script.removeAttribute('data-src'); } diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index d7cd7de9b85..3759ad9982e 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -191,7 +191,9 @@ class AssetsBundle(object): src = self.get_debug_asset_url(name=js_attachment.name, extension='') if is_debug_assets else js_attachment[0].url attr = dict([ ["async", "async" if async_load else None], - ["defer", "defer" if defer_load or lazy_load else None], + # lazy_load will add defer in JS otherwise this is not W3C valid + # (defer is probably not needed there anyways) + ["defer", "defer" if defer_load else None], ["type", "text/javascript"], ["data-src" if lazy_load else "src", src], ['data-asset-bundle', self.name], diff --git a/odoo/addons/base/models/ir_qweb.py b/odoo/addons/base/models/ir_qweb.py index d6f7755a659..8b7a3e4e155 100644 --- a/odoo/addons/base/models/ir_qweb.py +++ b/odoo/addons/base/models/ir_qweb.py @@ -2512,7 +2512,9 @@ class IrQWeb(models.AbstractModel): "type": mimetype, } attributes["data-src" if lazy_load else "src"] = path - if defer_load or lazy_load: + if defer_load: + # lazy_load will add defer in JS otherwise this is not + # W3C valid (defer is probably not needed there anyways) attributes["defer"] = "defer" elif is_css: tag = 'link'