Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading {google_map} after the entire page has loaded? currently adding some 4 sec to the whole page loading time #24

Closed
olivdee opened this issue Apr 26, 2016 · 3 comments

Comments

@olivdee
Copy link

olivdee commented Apr 26, 2016

hi and thanks for the great plugin!
we are in the process of optimizing a website using it, and the problem is that because it takes ages to load all gmap ressources (4 sec) the preloader/spinner on the website is still not showing content. our preloader/spinner fades out and reveales the content after "load" event. is it somehow possible to load all content by {google_map} after the "load" event = after the entire page has loaded?
any info/help/idea appreciated!

@petkivim
Copy link
Owner

Hi,

You could try the script below and see if it helps. It removes the value of src attribute from all the iframes on ready event which prevents them loading. The values are restored on load event with 2 seconds delay.

(function ($)
{
    // Array for frame sources
    var sources = [];

    $(document).ready(function ()
    {
        // Loop through all the iframes on the page
        $("iframe").each(function () {
            // Get the value of src
            var src = $(this).attr('src');
            // Set src=""
            $(this).attr('src', '');
            // Store src in the array
            sources.push(src);
        });
    });

    $(window).load(function () {

        function loadGMaps() {
            var i = 0;
            // Loop through all the iframes on the page
            $("iframe").each(function () {
                // Get src value from the array
                $(this).attr('src', sources[i]);
                i++;
            });
        }
        // Set 2 seconds delay for loading Google Maps
        setTimeout(loadGMaps, 2000);
    });
})(jQuery);

@olivdee
Copy link
Author

olivdee commented Apr 27, 2016

great idea/solution. works like a charm! thanks so much

@petkivim
Copy link
Owner

You're welcome. That's great to hear. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants