Skip to content

Commit 0360cdd

Browse files
authored
Merge pull request #324 from marclucraft/patch-1
Updated async attribute.
2 parents 4da98ff + 0cae2cd commit 0360cdd

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

onesignal-public.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
defined('ABSPATH') or die('This page may not be accessed directly.');
44

5-
function add_async_for_script($url)
6-
{
7-
if (strpos($url, '#asyncload') === false)
8-
return $url;
9-
else if (is_admin())
10-
return str_replace('#asyncload', '', $url);
11-
else
12-
return str_replace('#asyncload', '', $url)."' async='async";
13-
}
14-
155
class OneSignal_Public
166
{
177
public function __construct()
@@ -77,13 +67,11 @@ public static function onesignal_header()
7767
OneSignal_Public::insert_onesignal_stamp();
7868
} ?>
7969
<?php
80-
add_filter('clean_url', 'add_async_for_script', 11, 1);
81-
8270
if (defined('ONESIGNAL_DEBUG') && defined('ONESIGNAL_LOCAL')) {
83-
wp_register_script('local_sdk', 'https://localhost:3001/sdks/OneSignalSDK.js#asyncload', array(), false, true);
71+
wp_register_script('local_sdk', 'https://localhost:3001/sdks/OneSignalSDK.js', array(), '1.0.0', array('strategy' => 'async'));
8472
wp_enqueue_script('local_sdk');
8573
} else {
86-
wp_register_script('remote_sdk', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js#asyncload', array(), false, true);
74+
wp_register_script('remote_sdk', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js', array(), '1.0.0', array('strategy' => 'async'));
8775
wp_enqueue_script('remote_sdk');
8876
} ?>
8977
<script>

0 commit comments

Comments
 (0)