Skip to content

Commit

Permalink
[ADD] website_js_below_the_fold
Browse files Browse the repository at this point in the history
[IMP] Description of the problem

[ADD] Copyright banner
  • Loading branch information
tarteo authored and smurf-U committed Jan 8, 2019
1 parent 8a521f3 commit e2c8f4a
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
64 changes: 64 additions & 0 deletions website_js_below_the_fold/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=========================
Website JS Below The Fold
=========================

This module moves Javascript assets to the bottom of the page (below the fold)
preventing your website having render-blocking Javascript.

When a visitor enters your website the browser will parse the HTML result.
Whenever the parser encounters a script, it has to load and execute the script before it can continue parsing.
So with render-blocking Javascript (e.g. in the head tag) the time to render the above the fold content increases.

Without render-blocking Javascript (by e.g. loading it below the fold) the page first render occurs faster.
This may result in various benefits e.g. lower bounce rate.

More information:

* `Render-blocking Javascript <https://developers.google.com/speed/docs/insights/BlockingJS>`_
* `Above the fold <https://en.wikipedia.org/wiki/Above_the_fold>`_

Usage
=====

This is a technical module and have no graphical interface whatsoever.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/186/11.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/website/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Contributors
------------

* Dennis Sluijk <[email protected]>

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
Empty file.
19 changes: 19 additions & 0 deletions website_js_below_the_fold/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 Onestein
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Website JS Below The Fold',
'summary': 'This module moves Javascript assets '
'to the bottom of the page (below the fold)',
'category': 'Website',
'version': '11.0.1.0.0',
'author': 'Onestein, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/website',
'depends': [
'website'
],
'data': [
'templates/website_js_below_the_fold.xml'
]
}
43 changes: 43 additions & 0 deletions website_js_below_the_fold/templates/website_js_below_the_fold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Onestein
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->

<odoo>
<template id="layout" inherit_id="website.layout">
<!-- Remove js -->
<xpath expr="//t[@t-call-assets='web.assets_common'][@t-css='false']" position="attributes">
<attribute name="t-js">false</attribute>
</xpath>
<xpath expr="//t[@t-call-assets='web.assets_frontend'][@t-css='false']" position="attributes">
<attribute name="t-js">false</attribute>
</xpath>
<xpath expr="//t[@t-call-assets='web_editor.summernote'][@t-css='false']" position="attributes">
<attribute name="t-js">false</attribute>
</xpath>
<xpath expr="//t[@t-call-assets='web_editor.assets_editor'][@t-css='false']" position="attributes">
<attribute name="t-js">false</attribute>
</xpath>
<xpath expr="//t[@t-call-assets='website.assets_editor'][@t-css='false']" position="attributes">
<attribute name="t-js">false</attribute>
</xpath>

<!-- When the is user a publisher add js to top of the page (below the fold is not relevant here) -->
<xpath expr="//t[@t-call-assets='website.assets_editor'][@t-css='false']" position="after">
<t groups="website.group_website_publisher">
<t t-call-assets="web.assets_common" t-css="false"/>
<t t-call-assets="web.assets_frontend" t-css="false"/>
<t t-call-assets="web_editor.summernote" t-css="false"/>
<t t-call-assets="web_editor.assets_editor" t-css="false"/>
<t t-call-assets="website.assets_editor" t-css="false"/>
</t>
</xpath>

<!-- Add to bottom of page -->
<xpath expr="//div[@id='wrapwrap']" position="after">
<t groups="!website.group_website_publisher">
<t t-call-assets="web.assets_common" t-css="false"/>
<t t-call-assets="web.assets_frontend" t-css="false"/>
</t>
</xpath>
</template>
</odoo>

0 comments on commit e2c8f4a

Please sign in to comment.