data-preload

Morgan Borley 1 Reputation point
2022-06-27T07:09:23.407+00:00

Hi all,

Currently I have a page changing layout AFTER its first paint using JS which has been added like so:

<script type="text/javascript" src="/interfaceJS/ContentDefinition/SelfAssertedUnifiedSignInSignUp.min.js" data-preload="true"></script>

It was my impression that setting data-preload to "true" should run the JS before the page is rendered.

Currently the JS is only executed AFTER the page renders, this results in components flickering around the page as they are rearranged after the inital render.

Please let me know if this data-preload's expected behaviour.

Cheers,

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,431 Reputation points Microsoft Employee Moderator
    2022-07-04T11:02:16.927+00:00

    Hi @Morgan Borley ,

    Thanks for reaching out and apologies for delay in response.

    Your understanding is correct here and you can add the data-preload="true" attribute in your HTML tags which constructed the page before being shown to the user. This attribute helps prevent the page from "flickering" by preloading the CSS file, without the un-styled HTML being shown to the user.

    It seems data-preload= "true" is getting ignored with script tag and is not working properly.
    There are some guidelines for using JavaScript with Azure AD B2C as mentioned here. Make sure you are following those to enable javascript.

    Also, Enable the javascript for your User Flow as below:

    217270-image.png

    and specify a page layout name and version.

    217353-image.png

    Reference of CSS file to use data-preload in HTML file: https://learn.microsoft.com/en-us/azure/active-directory-b2c/customize-ui-with-html?pivots=b2c-user-flow#guidelines-for-using-custom-page-content

    Hope this will help. If you will not be able to resolve the issue, please let us know to assist you further.

    Thanks,
    Shweta

    --------------------------------

    Please remember to "Accept Answer" if answer helped you.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.