2017.9.28 地图延迟加载
 
                            2种方法
1通常用在正常的html页面内
<div class="map"></div>function loadgooglemap() {
	setTimeout(function () {
		$(".map").load('assets/gm.html');
	}, 500);
}
    
    
    
$(window).on("load", function () {
	loadgooglemap();
});
2通常用在wordpress内写在function.php内
function homeScript(){
    ?>
    <script>
        <?php wp_reset_query(); if ( !is_paged() && ( is_home() || is_front_page() ) ) { ?>
        jQuery(window).on('load', function() {
            setTimeout(function() {
                jQuery("#facebook").load('<?php bloginfo('url');?>/mp/facebook.html');
            }, 500);
        });
        <?php } ?>
    </script>
    <?php }
add_action( 'wp_footer', 'homeScript', 100, 1 );
function embedGoogleMap() {
    if ($(".footer-map").find("iframe").length) {
        var map = $(".footer-map").html();
        $(".footer-map").find("iframe").remove();
        $(window).on("load", function () {
            setTimeout(function () {
                $(".footer-map").html(map);
            }, 500);
        });
    }
}
// 在ready事件中执行函数
$(function () {
embedGoogleMap();
});相关文章
        
    