I have a unique issue where I am loading a lot of iframes on a page and it significantly reduces performance.
Since they are all inside of popup modals, I want to trigger the iframe to load after someone clicks on the modal.
When the modal loads using JS, a class is added called '.in' and this data attribute is changed from true to false "aria-hidden="false".
Here is a sample of the DIV as the trigger:
<div id="ModalPopUp-data-integration-service" class="modal hide fade in" data-
backdrop="true" data-keyboard="true" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: block;">
Here is the iframe I want to load:
<iframe src="http://XXXXX.com" width="100%" height="800" type="text/html" frameborder="0" allowtransparency="true" style="border: 0"></iframe>
I want to trigger the iframe to load after someone clicks on the modal
You have to better describe what behaviour you are expecting? Which click? And see @Jas comment, just setsrc
attribute of iframe when needed – A. WolffMutation Observer
to observe changes in the DOM on an element. Have a look at the MDN Docs on Mutation Observers – Ohgodwhy