FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Do not run script twice if it is loaded twice · binarweb/scripts@4d2ab81 · GitHub

Repository navigation

Commit 4d2ab81

Browse files
authored andcommitted
Do not run script twice if it is loaded twice
1 parent 0e5e8f7 commit 4d2ab81

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎minify.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const GREEN = "\x1b[32m%s\x1b[0m";
88
const YELLOW = "\x1b[33m%s\x1b[0m";
99
const RED = "\x1b[31m%s\x1b[0m";
1010

11-
const VERSION = 6;
11+
const VERSION = 7;
1212

1313
Handlebars.registerHelper("or", function (param1, param2) {
1414
return param1 || param2;

‎src/default.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
/* eslint-env browser */
22

33
(function (window, overwriteOptions, baseUrl, apiUrlPrefix, version, saGlobal) {
4-
if (!window) return;
54
try {
5+
// Only load our script once, customers can still send multiple page views
6+
// with the sa_pageview function if they turn off auto collect.
7+
var loadedVariable = saGlobal + "_loaded";
8+
if (!window || window[loadedVariable] === true) return;
9+
window[loadedVariable] = true;
10+
611
/////////////////////
712
// PREDEFINED VARIABLES FOR BETTER MINIFICATION
813
//

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL