Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2016-09-15 01:13:35 +0300
committerThomas Steur <thomas.steur@gmail.com>2016-09-15 01:13:35 +0300
commit783e3f544a71e48b3bc4740420904021404f422a (patch)
tree4ff9c80834fe03402f31badeac99fe0b82e5eb06
parent41d93d1c1b405d5fcf1cd86c86e3158f18aefe14 (diff)
added a new option for plugins to load piwik js synchronous
-rw-r--r--core/Tracker/TrackerCodeGenerator.php10
-rw-r--r--plugins/Morpheus/templates/javascriptCode.tpl2
2 files changed, 10 insertions, 2 deletions
diff --git a/core/Tracker/TrackerCodeGenerator.php b/core/Tracker/TrackerCodeGenerator.php
index c985db88e7..ae1ef6d2e8 100644
--- a/core/Tracker/TrackerCodeGenerator.php
+++ b/core/Tracker/TrackerCodeGenerator.php
@@ -119,7 +119,8 @@ class TrackerCodeGenerator
'piwikUrl' => Common::sanitizeInputValue($piwikUrl),
'options' => $options,
'optionsBeforeTrackerUrl' => $optionsBeforeTrackerUrl,
- 'protocol' => '//'
+ 'protocol' => '//',
+ 'loadAsync' => true
);
$parameters = compact('mergeSubdomains', 'groupPageTitlesByDomain', 'mergeAliasUrls', 'visitorCustomVariables',
'pageCustomVariables', 'customCampaignNameQueryParam', 'customCampaignKeywordParam',
@@ -141,6 +142,7 @@ class TrackerCodeGenerator
* the JavaScript tracker inside of anonymous function before
* adding setTrackerUrl into paq.
* - **protocol**: Piwik url protocol.
+ * - **loadAsync**: boolean whether piwik.js should be loaded syncronous or asynchronous
*
* The **httpsPiwikUrl** element can be set if the HTTPS
* domain is different from the normal domain.
@@ -148,6 +150,12 @@ class TrackerCodeGenerator
*/
Piwik::postEvent('Piwik.getJavascriptCode', array(&$codeImpl, $parameters));
+ if (!empty($codeImpl['loadAsync'])) {
+ $codeImpl['loadAsync'] = 'true';
+ } else {
+ $codeImpl['loadAsync'] = 'false';
+ }
+
$setTrackerUrl = 'var u="' . $codeImpl['protocol'] . '{$piwikUrl}/";';
if (!empty($codeImpl['httpsPiwikUrl'])) {
diff --git a/plugins/Morpheus/templates/javascriptCode.tpl b/plugins/Morpheus/templates/javascriptCode.tpl
index 18483dd09d..1a9ea321c1 100644
--- a/plugins/Morpheus/templates/javascriptCode.tpl
+++ b/plugins/Morpheus/templates/javascriptCode.tpl
@@ -8,7 +8,7 @@
{$optionsBeforeTrackerUrl}_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '{$idSite}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
- g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+ g.type='text/javascript'; g.async={$loadAsync}; g.defer={$loadAsync}; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="{$protocol}{$piwikUrl}/piwik.php?idsite={$idSite}" style="border:0;" alt="" /></p></noscript>