cyberhobo / wordpress-geo-mashup

Official repository for Geo Mashup, the plugin that makes WordPress into a GeoCMS. Documentation:
https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Getting-Started
63 stars 15 forks source link

Incompatibility: Async Javascript #775

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi. Plugin is broken and maps doesn't render if I use this function:

// Make JavaScript Asynchronous in Wordpress add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if( is_admin() ) { return $tag; } return str_replace( ' src', ' async src', $tag ); }, 10, 2 );

cyberhobo commented 7 years ago

Wouldn't that break any script with dependencies, not just Geo Mashup?

ghost commented 7 years ago

Yes, some minor issues with WP User Frontend plugin, JavaScript related.

cyberhobo commented 7 years ago

I wouldn't expect this to work. Techniques that combine scripts with respect to dependencies might allow asynchronous loading.

ghost commented 7 years ago

I've checked twice: if I remove code, maps are rendered, if I save into my FUNCTIONS.PHP Geo Maps doesn't work. Time ago I wrote you about problem deferring Javascript too. Some incompatibilities with this?

cyberhobo commented 7 years ago

As you agreed, the snippet you posted will potentially break any scripts with dependencies. I'd say the snippet is not compatible with WordPress script loading.