Scripts are not loading when multiple components are added on the page | Community
Skip to main content
Level 3
May 20, 2022
Solved

Scripts are not loading when multiple components are added on the page

  • May 20, 2022
  • 3 replies
  • 1557 views

Hi All,

 

We had designed a component to generate dynamic script values based on the author inputs to display ads on the page.So , on adding multiple AD components  , script results are showing up only in the last component added on the page. Eventhough ID is unique to each component ,response is not shown in all the components added .Could you please suggest ways to fix this issue.

 

Used ${resource.path.hashCode} to generate the unique ID in each component.

id="testcontainer${resource.path.hashCode}

 

Thanks in Advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

Loading wound not be an issue bit executing javascript can be because of id.

Can you check if the javascript file is loading or not?

3 replies

May 20, 2022

Please take a closer look at your JavaScript code, as maybe it will only add behavior to "one" element on the page. 

B_Sravan
Community Advisor
Community Advisor
May 21, 2022

Definitely not an issue with adding multiple components. Please check your java script.

arunpatidar
Community Advisor
Community Advisor
May 21, 2022

I would suggesting to update java script logic to handle multiple instance of the AD.

Loading 10 instance of script for 10 AD component does not make sense from performance perspective.

Arun Patidar
Keerthi97Author
Level 3
May 23, 2022

Hi @arunpatidar ,

 

Thanks for your response.

 

While inspecting through component element , i can see special characters is getting added on the last before components on the page .

Working-Scripts loaded:

id=testcontainer132456

 

Working-Scripts Not loaded:

id=testcontainer-132456

 

So , could anyone please let me know whether this may cause the script to not load on the page.

 

Thanks in Advance!

Keerthi97Author
Level 3
May 25, 2022

Hi,

Loading wound not be an issue bit executing javascript can be because of id.

Can you check if the javascript file is loading or not?


Hi ,

Javascript file is been loading but when adding the lazyload function , scripts are loading only in the last  component on the page.So , could you please help me to further troubleshoot this issue .

 

Thanks!