Viewing 5 replies - 1 through 5 (of 5 total)
  • Adding defer=”defer” to plugin scripts is unfortunately not possible due to compatibility issues.
    Can you please tell me which code you changed so that I can check if we can add some improvements here?
    thx!

    Thread Starter ensemblebd

    (@ensemblebd)

    Hi there, I think I’ll need to do some kind of diff or pull request for you on this one, it’s a bit complicated to list out here. I changed the leaflet.js and the showmap.php to wrap their javascript executions, changed leaflet-maps-marker.php to load ‘leafletmapsmarker-googlemaps-loader’ prior to jsapi (for callback), added a callback parameter to jsapi alongside the google api key and forced all scripts to use the defer attribute. The javascript code runs precautionary sanity checks using setInterval to determine when to execute the counterparts (though via debugging it didn’t seem to need that).

    One particular downside is I’m using a WP vers 4.5 feature wp_add_inline_script, since it was the quickest solution to get the callback into the correct spot. So that rules out some of the backwards compat for certain peoples. A second downside, is I’m hooking the document.write function, to perform a $(‘body’).append(jsapi_code), then restoring it afterwards. Why is google writing to the document buffer anyway, that’s so year 2000. ??

    It works great, but I am unsure on it’s suitability for public consumption. I think you guys may be able determine a more elegant way to handle this, but let me know how best to get the codeset over to you

    Thread Starter ensemblebd

    (@ensemblebd)

    thanks a lot! we will check if we can enhance our plugin in general in the same way – although this might be tricky (especially for multiple maps on 1 page for example)

    Hi,
    we took a look again on how we could add async loading of scripts. Not sure if your solution would work for all users. May I ask you if your code also works if there are multiple different maps on 1 page? Could you also provide a link to a test page where I have a look at your solution?
    best & thx,
    Robert

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Async JSAPI would be nice’ is closed to new replies.