Legacy Knowledge Base
Published Jul. 2, 2025

Using Position Taglibs in Embedded Portlets

Written By

Antonio Ortega

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

This article documents how to make use of four different position taglibs while using the Liferay platform. The four taglibs are: BodyBottomTagBodyTopTagHtmlBottomTag and HtmlTopTag.

These taglibs will position the code that is included within them at the top or bottom of the specified area in the Document Object Model (DOM). You can also embed portlets in your theme. This article provides you with information and examples on how to use these position taglibs.

Resolution

If you include one of the position taglibs inside a portlet, the default behavior is going to be slightly different depending on whether the portlet is or is not embedded.

  • Portlet Not Embedded

    If the portlet is not embedded, the taglib would include the code at the top or the bottom.

  • Portlet Is Embedded

    If the portlet is embedded, the taglib would include the code inline. That means, in the same position where the portlet is embedded.

The reason why an embedded portlet functions in this way is because it follows after loading JavaScript, which helps to avoid performance issues while rendering embedded portlets.

In case you want to have an embedded portlet with a position taglib—of which the default behavior is to show the code at the top or the bottom—you need to make use of the attribute position with value auto in that taglib. Below you can see an example of part of the code of an embedded portlet:

Without Using the Attribute Position:

<liferay-util:html-bottom>
    <script>
        console.log('This log will be executed inline.');
    </script>
</liferay-util:html-bottom>

Using the Attribute Position:

<liferay-util:html-bottom position="auto">
    <script>
        console.log('This log will be executed at the bottom.');
    </script>
</liferay-util:html-bottom>

 

Did this article resolve your issue ?

Legacy Knowledge Base