1

I have created a custom module in which I created a popup modal in custom location.js with require js on and add this js in default.xml file.

On the first page load popup is open after the page load i want to load this js before the page load.

Here's the default.xml wihich I override

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
 <link src="Vendor_Module::js/location.js"/>
</head>
<body>
 <referenceContainer name="page.wrapper">
 <block class="Magento\Framework\View\Element\Template" name="custom-block-name" template="Vendor_Module::popup.phtml" ifconfig="nearbyproducts/general/enable"/>
 </referenceContainer>
</body>

Can you please suggest how can I load js before page load or stop the page load?

asked Sep 24, 2022 at 14:57
4
  • Hi Divya, your question is bit unclear for me. Can you elaborate a little more? what is your js file actually trying to do? I dont think stopping page load for a js file is a good idea. Javascript files are by default blockers during page load unless you make them async. Commented Sep 25, 2022 at 6:14
  • Hi there , can you please share the script here ? I am guessing you could move your script in the head tag and write events that when a dom element is loaded it could trigger. Commented Sep 25, 2022 at 8:33
  • Hi @RajeevKTomy, I created a Zipcode popup in js file when we enter zipcode then products will be come according to distance. Commented Sep 25, 2022 at 11:27
  • Hi @RajeevKTomy, Issue is that In catalog product page when I enter zipcode product are come from cache they will not short and after clean the cache product will show correctly. I hope it's clear for you. Commented Sep 25, 2022 at 11:50

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.