How can I delay the loading of an iFrame? The iFrame (at bottom of page) is:
- A) Slowing the site load time
- B) Conflicting with slider (see my other question re: slider)
To delay the iframe load until after DOM ready I'm trying:
<iframe id="iframe_id" src="http://sourcewebsite.com" style="width:100%;height:700px;border:0px;background-color:;" frameborder="0" allowtransparency="true"></iframe>
<script type='text/javascript'> $(document).ready(function(){ $('iframe#iframe_id').attr('src', 'http://sourcewebsite.com'); }); </script>
I'm assuming this takes http://sourcewebsite.com and passes it to 'src' and loads it into the iframe with the id #iframe_id after DOM is ready
However chrome developer console is telling me:
"Uncaught ReferenceError: $ is not defined"
.
At the moment I'm thinking (window).load my be a better method as it would load the iframe after the slider.. eg:
<iframe id="iframe_id" src="http://sourcewebsite.com"..........></iframe>
$(window).load(function() { $('iframe#iframe_id').attr('src', 'http://sourcewebsite.com'); });
But I'm not sure if this is syntax is correct (especially the url in the script and iframe#iframe instead of just #iframe) Please free to let me know if there are any mistakes! Judging by how things are going I'm sure there are!
Thanks for any tips!
EDIT - Re: scripts:
!-- JAVASCRIPT FILES PLACED AT THE BOTTOM TO REDUCE THE LOADING TIME -->
<!-- CORE JQUERY -->
<script src="assets/js/jquery-1.11.1.js"></script>
<!-- BOOTSTRAP SCRIPTS -->
<script src="assets/js/bootstrap.js"></script>
<!-- EASING SCROLL SCRIPTS PLUGIN
<script src="assets/js/vegas/jquery.vegas.min.js"></script>
<!-- VEGAS SLIDESHOW SCRIPTS -->
<script src="assets/js/jquery.easing.min.js"></script>
<!-- FANCYBOX PLUGIN -->
<script src="assets/js/source/jquery.fancybox.js"></script>
<!-- ISOTOPE SCRIPTS -->
<script src="assets/js/jquery.isotope.js"></script>
<!-- VIEWPORT ANIMATION SCRIPTS -->
<script src="assets/js/appear.min.js"></script>
<script src="assets/js/animations.min.js"></script>
<!-- CUSTOM SCRIPTS -->
<script src="assets/js/custom.js"></script>