From d3ce71fff812eaf73f009bfd1ea02a8faef3281c Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Sun, 25 Aug 2024 23:59:00 +0200 Subject: [PATCH 1/6] remove ie9 support --- src/oc-client.js | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/oc-client.js b/src/oc-client.js index 92a6544..bfefb7e 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -47,8 +47,6 @@ var oc = oc || {}; // The code var $, noop = function () {}, - nav = $window.navigator.userAgent, - is9 = !!nav.match(/MSIE 9/), initialised = false, initialising = false, retries = {}, @@ -78,11 +76,8 @@ var oc = oc || {}; }; // constants - var CDNJS_BASEURL = 'https://cdnjs.cloudflare.com/ajax/libs/', - IE9_AJAX_POLYFILL_URL = - CDNJS_BASEURL + - 'jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js', - JQUERY_URL = CDNJS_BASEURL + 'jquery/3.6.0/jquery.min.js', + var JQUERY_URL = + 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js', RETRY_INTERVAL = ocConf.retryInterval || __DEFAULT_RETRY_INTERVAL__, RETRY_LIMIT = ocConf.retryLimit || __DEFAULT_RETRY_LIMIT__, DISABLE_LOADER = isBool(ocConf.disableLoader) @@ -412,14 +407,6 @@ var oc = oc || {}; } else { initialising = true; - var requirePolyfills = function ($, cb) { - if (is9 && !$.IE_POLYFILL_LOADED) { - oc.require(IE9_AJAX_POLYFILL_URL, cb); - } else { - cb(); - } - }; - var done = function () { initialised = true; initialising = false; @@ -458,14 +445,12 @@ var oc = oc || {}; oc.require('jQuery', JQUERY_URL, function (jQuery) { oc.requireSeries(externals, function () { - requirePolyfills(jQuery, function () { - if (wasJqueryThereAlready || wasDollarThereAlready) { - $ = oc.$ = jQuery; - } else { - $ = oc.$ = jQuery.noConflict(); - } - done(); - }); + if (wasJqueryThereAlready || wasDollarThereAlready) { + $ = oc.$ = jQuery; + } else { + $ = oc.$ = jQuery.noConflict(); + } + done(); }); }); } From 4f76e036f1b54787a2578d0a9a15bf206cf0a194 Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Mon, 26 Aug 2024 00:15:23 +0200 Subject: [PATCH 2/6] remove ie9 references --- src/oc-client.js | 14 +++++++------- tasks/karma.js | 14 ++------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/oc-client.js b/src/oc-client.js index bfefb7e..c8c2b12 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -125,7 +125,7 @@ var oc = oc || {}; } var retry = function (component, cb, failedRetryCb) { - if (retries[component] === undefined) { + if (retries[component] == undefined) { retries[component] = RETRY_LIMIT; } @@ -311,7 +311,7 @@ var oc = oc || {}; crossDomain: true, success: function (apiResponse) { var response = apiResponse[0].response; - if (response.renderMode === 'rendered') { + if (response.renderMode == 'rendered') { return cb(MESSAGES_ERRORS_GETTING_DATA); } var error = response.error ? response.details || response.error : null; @@ -459,7 +459,7 @@ var oc = oc || {}; oc.render = function (compiledViewInfo, model, callback) { oc.ready(function () { // TODO: integrate with oc-empty-response-handler module - if (model && model.__oc_emptyResponse === true) { + if (model && model.__oc_emptyResponse == true) { return callback(null, ''); } @@ -573,7 +573,7 @@ var oc = oc || {}; } oc.ready(function () { - if (href !== '') { + if (href) { var extraParams = RETRY_SEND_NUMBER ? { __oc_Retry: retryNumber } : {}; var finalisedHref = addParametersToHref( href, @@ -586,7 +586,7 @@ var oc = oc || {}; contentType: 'text/plain', crossDomain: true, success: function (apiResponse) { - if (apiResponse.renderMode === 'unrendered') { + if (apiResponse.renderMode == 'unrendered') { apiResponse.data.id = id; oc.render( apiResponse.template, @@ -616,7 +616,7 @@ var oc = oc || {}; }); } ); - } else if (apiResponse.renderMode === 'rendered') { + } else if (apiResponse.renderMode == 'rendered') { logger.info( MESSAGES_RENDERED.replace(firstPlaceholder, apiResponse.href) ); @@ -641,7 +641,7 @@ var oc = oc || {}; }, error: function (error) { var status = error && error.status; - if (status === 429) retries[href] = 0; + if (status == 429) retries[href] = 0; logger.error(MESSAGES_ERRORS_RETRIEVING); retry( href, diff --git a/tasks/karma.js b/tasks/karma.js index 3c7b6c2..ee0e8e8 100644 --- a/tasks/karma.js +++ b/tasks/karma.js @@ -41,12 +41,6 @@ const customLaunchers = { platform: 'Windows 8', version: '10' }, - ie9: { - base: 'SauceLabs', - browserName: 'internet explorer', - platform: 'Windows 7', - version: '9' - }, safari: { base: 'SauceLabs', browserName: 'Safari', @@ -86,12 +80,8 @@ module.exports = { browsers: ['chrome', 'ff', 'android'] }, 'sauce-windows': { - customLaunchers: _.pick(customLaunchers, 'edge14', 'ie11', 'ie10', 'ie9'), - browsers: ['edge14', 'ie11', 'ie10', 'ie9'] - }, - 'sauce-ie9': { - customLaunchers: _.pick(customLaunchers, 'ie9'), - browsers: ['ie9'] + customLaunchers: _.pick(customLaunchers, 'edge14', 'ie11'), + browsers: ['edge14', 'ie11'] }, 'sauce-osx': { customLaunchers: _.pick(customLaunchers, 'safari', 'iphone', 'ipad'), From 6787bb1c17e9e77cfd7ca39defb09e5190b759b4 Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Mon, 26 Aug 2024 00:23:14 +0200 Subject: [PATCH 3/6] share settimeout --- src/oc-client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/oc-client.js b/src/oc-client.js index c8c2b12..e6e98a1 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -56,6 +56,7 @@ var oc = oc || {}; isFunction = function (a) { return typeof a == 'function'; }, + timeout = setTimeout, ocCmd = oc.cmd, ocConf = oc.conf, renderedComponents = oc.renderedComponents, @@ -133,7 +134,7 @@ var oc = oc || {}; return failedRetryCb(); } - setTimeout(function () { + timeout(function () { cb(RETRY_LIMIT - retries[component] + 1); }, RETRY_INTERVAL); retries[component]--; @@ -551,7 +552,7 @@ var oc = oc || {}; } ); } else { - setTimeout(callback, POLLING_INTERVAL); + timeout(callback, POLLING_INTERVAL); } }); }; From d2deb09b02722733eb0067b76fdb5daa0b9502e5 Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Mon, 26 Aug 2024 00:35:34 +0200 Subject: [PATCH 4/6] reduce bytes --- src/oc-client.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/oc-client.js b/src/oc-client.js index e6e98a1..bacc666 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -237,7 +237,7 @@ var oc = oc || {}; loaded = []; } - if (toLoad.length == 0) { + if (!toLoad.length) { return callback(); } @@ -486,10 +486,12 @@ var oc = oc || {}; asyncRequireForEach(template.externals, function () { if (type == 'oc-template-handlebars') { try { - var linked = $window.Handlebars.template(compiledView, []); - callback(null, linked(model)); + callback( + null, + $window.Handlebars.template(compiledView, [])(model) + ); } catch (e) { - callback(e.toString()); + callback(String(e)); } } else { callback(null, compiledView(model)); From 1fb809236390ff5574c4a60d04f6e81eabfb7c4c Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Mon, 26 Aug 2024 16:55:45 +0200 Subject: [PATCH 5/6] reduce even more bytes --- src/oc-client.js | 68 ++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/src/oc-client.js b/src/oc-client.js index bacc666..dd92d1d 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -63,18 +63,13 @@ var oc = oc || {}; firstPlaceholder = '{0}', secondPlaceholder = '{1}', dataRenderedAttribute = 'data-rendered', - dataRenderingAttribute = 'data-rendering'; - - var logger = { - error: function (msg) { - // eslint-disable-next-line no-console - return console.log(msg); + dataRenderingAttribute = 'data-rendering', + error = function (msg) { + console.log(msg); }, - info: function (msg) { - // eslint-disable-next-line no-console - return ocConf.debug ? console.log(msg) : false; - } - }; + info = function (msg) { + ocConf.debug && console.log(msg); + }; // constants var JQUERY_URL = @@ -141,16 +136,7 @@ var oc = oc || {}; }; var addParametersToHref = function (href, parameters) { - if (href && parameters) { - var param = $.param(parameters); - if (href.indexOf('?') > -1) { - return href + '&' + param; - } else { - return href + '?' + param; - } - } - - return href; + return href + ~href.indexOf('?') ? '&' : '?' + $.param(parameters); }; var getHeaders = function () { @@ -318,9 +304,7 @@ var oc = oc || {}; var error = response.error ? response.details || response.error : null; return cb(error, response.data, apiResponse[0]); }, - error: function (err) { - return cb(err); - } + error: cb }; if (jsonRequest) { ajaxOptions.dataType = 'json'; @@ -491,7 +475,7 @@ var oc = oc || {}; $window.Handlebars.template(compiledView, [])(model) ); } catch (e) { - callback(String(e)); + callback('' + e); } } else { callback(null, compiledView(model)); @@ -525,7 +509,7 @@ var oc = oc || {}; : dataRendered == 'true'; if (!isRendering && !isRendered) { - logger.info(MESSAGES_RETRIEVING); + info(MESSAGES_RETRIEVING); attr(dataRenderingAttribute, true); if (!DISABLE_LOADER) { $component.html( @@ -537,16 +521,16 @@ var oc = oc || {}; { href: attr('href'), id: attr('id') }, function (err, data) { if (err || !data) { - attr(dataRenderingAttribute, 'false'); - attr(dataRenderedAttribute, 'false'); - attr('data-failed', 'true'); + attr(dataRenderingAttribute, false); + attr(dataRenderedAttribute, false); + attr('data-failed', true); $component.html(''); oc.events.fire('oc:failed', { originalError: err, data: data, component: $component[0] }); - logger.error(err); + error(err); return callback(); } @@ -577,14 +561,15 @@ var oc = oc || {}; oc.ready(function () { if (href) { - var extraParams = RETRY_SEND_NUMBER ? { __oc_Retry: retryNumber } : {}; - var finalisedHref = addParametersToHref( - href, - $.extend({}, ocConf.globalParameters, extraParams) - ); - $.ajax({ - url: finalisedHref, + url: addParametersToHref( + href, + $.extend( + {}, + ocConf.globalParameters, + RETRY_SEND_NUMBER && { __oc_Retry: retryNumber } + ) + ), headers: getHeaders(), contentType: 'text/plain', crossDomain: true, @@ -603,7 +588,7 @@ var oc = oc || {}; ).replace(secondPlaceholder, err) ); } - logger.info( + info( MESSAGES_RENDERED.replace( firstPlaceholder, apiResponse.template.src @@ -620,7 +605,7 @@ var oc = oc || {}; } ); } else if (apiResponse.renderMode == 'rendered') { - logger.info( + info( MESSAGES_RENDERED.replace(firstPlaceholder, apiResponse.href) ); @@ -643,9 +628,8 @@ var oc = oc || {}; } }, error: function (error) { - var status = error && error.status; - if (status == 429) retries[href] = 0; - logger.error(MESSAGES_ERRORS_RETRIEVING); + if (error && error.status == 429) retries[href] = 0; + error(MESSAGES_ERRORS_RETRIEVING); retry( href, function (requestNumber) { From e915f585be95c1675922ab737437c963d2b1b18b Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Mon, 26 Aug 2024 17:11:32 +0200 Subject: [PATCH 6/6] fix shadow issues --- .eslintrc.json | 3 +- src/oc-client.js | 10 +- vendor/l.js | 241 ++++++++++++++++++++++++++--------------------- 3 files changed, 143 insertions(+), 111 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 40e525a..1ccb999 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,8 @@ ], "rules": { "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-empty-function": "off" + "@typescript-eslint/no-empty-function": "off", + "no-shadow": "error" }, "globals": { "oc": true, diff --git a/src/oc-client.js b/src/oc-client.js index dd92d1d..ed28242 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -136,7 +136,7 @@ var oc = oc || {}; }; var addParametersToHref = function (href, parameters) { - return href + ~href.indexOf('?') ? '&' : '?' + $.param(parameters); + return href + (~href.indexOf('?') ? '&' : '?') + $.param(parameters); }; var getHeaders = function () { @@ -301,8 +301,8 @@ var oc = oc || {}; if (response.renderMode == 'rendered') { return cb(MESSAGES_ERRORS_GETTING_DATA); } - var error = response.error ? response.details || response.error : null; - return cb(error, response.data, apiResponse[0]); + var err = response.error ? response.details || response.error : null; + return cb(err, response.data, apiResponse[0]); }, error: cb }; @@ -627,8 +627,8 @@ var oc = oc || {}; }); } }, - error: function (error) { - if (error && error.status == 429) retries[href] = 0; + error: function (err) { + if (err && err.status == 429) retries[href] = 0; error(MESSAGES_ERRORS_RETRIEVING); retry( href, diff --git a/vendor/l.js b/vendor/l.js index 9298a84..c8cc388 100644 --- a/vendor/l.js +++ b/vendor/l.js @@ -1,48 +1,47 @@ //https://github.com/malko/l.js (function (window, undefined) { /* - * script for js/css parallel loading with dependancies management - * @author Jonathan Gotti < jgotti at jgotti dot net > - * @contributors ivanrey, AlexGal0 - * @licence dual licence mit / gpl - * @since 2012-04-12 - * @todo add prefetching using text/cache for js files - * @changelog - * - 2023-02-28 - add support for module type thanks to PR#21 by AlexGal0 - * - 2019-01-17 - add support for error handlers + bugFix on multiple inclusion of filled script tag fix issues #15 and #17 - * - 2016-08-22 - remove global eval and fix issue #13 - * - 2014-06-26 - bugfix in css loaded check when hashbang is used - * - 2014-05-25 - fallback support rewrite + null id bug correction + minification work - * - 2014-05-21 - add cdn fallback support with hashbang url - * - 2014-05-22 - add support for relative paths for stylesheets in checkLoaded - * - 2014-05-21 - add support for relative paths for scripts in checkLoaded - * - 2013-01-25 - add parrallel loading inside single load call - * - 2012-06-29 - some minifier optimisations - * - 2012-04-20 - now sharp part of url will be used as tag id - * - add options for checking already loaded scripts at load time - * - 2012-04-19 - add addAliases method - * @note coding style is implied by the target usage of this script not my habbits - */ - var isA = function (a, b) { return a instanceof (b || Array); } + * script for js/css parallel loading with dependancies management + * @author Jonathan Gotti < jgotti at jgotti dot net > + * @contributors ivanrey, AlexGal0 + * @licence dual licence mit / gpl + * @since 2012-04-12 + * @todo add prefetching using text/cache for js files + * @changelog + * - 2023-02-28 - add support for module type thanks to PR#21 by AlexGal0 + * - 2019-01-17 - add support for error handlers + bugFix on multiple inclusion of filled script tag fix issues #15 and #17 + * - 2016-08-22 - remove global eval and fix issue #13 + * - 2014-06-26 - bugfix in css loaded check when hashbang is used + * - 2014-05-25 - fallback support rewrite + null id bug correction + minification work + * - 2014-05-21 - add cdn fallback support with hashbang url + * - 2014-05-22 - add support for relative paths for stylesheets in checkLoaded + * - 2014-05-21 - add support for relative paths for scripts in checkLoaded + * - 2013-01-25 - add parrallel loading inside single load call + * - 2012-06-29 - some minifier optimisations + * - 2012-04-20 - now sharp part of url will be used as tag id + * - add options for checking already loaded scripts at load time + * - 2012-04-19 - add addAliases method + * @note coding style is implied by the target usage of this script not my habbits + */ + var isA = function (a, b) { + return a instanceof (b || Array); + }, //-- some minifier optimisation - , D = document - , getElementsByTagName = 'getElementsByTagName' - , length = 'length' - , readyState = 'readyState' - , onreadystatechange = 'onreadystatechange' - , scriptStr = 'script' - , header = D[getElementsByTagName]("head")[0] || D.documentElement - , aliases = {} - //-- get the current script tag for further evaluation of it's eventual content - , scripts = D[getElementsByTagName](scriptStr) - , scriptTag = scripts[scripts[length] - 1] - , script = scriptTag.innerHTML.replace(/^\s+|\s+$/g, '') - , appendElmt = function (type, attrs, cb) { - var e = D.createElement(type), i; - if (cb) { //-- this is not intended to be used for link + D = document, + getElementsByTagName = 'getElementsByTagName', + length = 'length', + readyState = 'readyState', + onreadystatechange = 'onreadystatechange', + scriptStr = 'script', + header = D[getElementsByTagName]('head')[0] || D.documentElement, + appendElmt = function (type, attrs, cb) { + var e = D.createElement(type), + i; + if (cb) { + //-- this is not intended to be used for link if (e[readyState]) { e[onreadystatechange] = function () { - if (e[readyState] === "loaded" || e[readyState] === "complete") { + if (e[readyState] === 'loaded' || e[readyState] === 'complete') { e[onreadystatechange] = null; cb(); } @@ -51,29 +50,30 @@ e.onload = cb; } } - for (i in attrs) { attrs[i] && (e[i] = attrs[i]); } + for (i in attrs) { + attrs[i] && (e[i] = attrs[i]); + } header.appendChild(e); // return e; // unused at this time so drop it - } - ; + }; //avoid multiple inclusion to override current loader but allow tag content evaluation if (!window.ljs) { - var checkLoaded = scriptTag.src.match(/checkLoaded/) ? 1 : 0 - //-- keep trace of header as we will make multiple access to it - , urlParse = function (url) { + //-- keep trace of header as we will make multiple access to it + var urlParse = function (url) { var parts = {}; // u => url, i => id, f => fallback, m => is a module - parts.u = url.replace(/(^module:)|#(=)?([^#]*)?/g, function (_, m, f, i) { parts[m ? 'm' : f ? 'f' : 'i'] = !!m || i; return ''; }); + parts.u = url.replace( + /(^module:)|#(=)?([^#]*)?/g, + function (_, m, f, i) { + parts[m ? 'm' : f ? 'f' : 'i'] = !!m || i; + return ''; + } + ); return parts; - } - , load = function (loader, url, cb) { - if (aliases && aliases[url]) { - var args = aliases[url].slice(0); - isA(args) || (args = [args]); - cb && args.push(cb); - return loader.load.apply(loader, args); - } - if (isA(url)) { // parallelized request - for (var l = url[length]; l--;) { + }, + load = function (loader, url, cb) { + if (isA(url)) { + // parallelized request + for (var l = url[length]; l--; ) { loader.load(url[l]); } cb && url.push(cb); // relaunch the dependancie queue @@ -83,82 +83,113 @@ return loader.loadcss(url, cb); } return loader.loadjs(url, cb); - } - , loaded = {} // will handle already loaded urls - , errorHandlers = [] - , loader = { - aliases: aliases - , loadjs: function (url, cb) { + }, + loaded = {}, // will handle already loaded urls + errorHandlers = [], + loader = { + loadjs: function (url, cb) { var parts = urlParse(url); - var onError = function (url) { for (var i = 0, l = errorHandlers.length; i < l; i++) { errorHandlers[i](url) } }; + var onError = function (url) { + for (var i = 0, l = errorHandlers.length; i < l; i++) { + errorHandlers[i](url); + } + }; var type = parts.m ? 'module' : 'text/javascript'; url = parts.u; - if (loaded[url] === true) { // already loaded exec cb if any + if (loaded[url] === true) { + // already loaded exec cb if any cb && cb(); return loader; - } else if (loaded[url] !== undefined) { // already asked for loading we append callback if any else return + } else if (loaded[url] !== undefined) { + // already asked for loading we append callback if any else return if (cb) { - loaded[url] = (function (ocb, cb) { return function () { ocb && ocb(); cb && cb(); }; })(loaded[url], cb); + loaded[url] = (function (ocb, cb) { + return function () { + ocb && ocb(); + cb && cb(); + }; + })(loaded[url], cb); } return loader; } // first time we ask this script - loaded[url] = (function (cb) { return function () { loaded[url] = true; cb && cb(); }; })(cb); - cb = function () { loaded[url](); }; + loaded[url] = (function (cb) { + return function () { + loaded[url] = true; + cb && cb(); + }; + })(cb); + cb = function () { + loaded[url](); + }; - appendElmt(scriptStr, { - type: type, src: url, id: parts.i, onerror: function (error) { - onError(url); - var c = error.currentTarget; - c.parentNode.removeChild(c); - appendElmt(scriptStr, { type: type, src: parts.f, id: parts.i, onerror: function () { onError(parts.f) } }, cb); - } - }, cb); + appendElmt( + scriptStr, + { + type: type, + src: url, + id: parts.i, + onerror: function (error) { + onError(url); + var c = error.currentTarget; + c.parentNode.removeChild(c); + appendElmt( + scriptStr, + { + type: type, + src: parts.f, + id: parts.i, + onerror: function () { + onError(parts.f); + } + }, + cb + ); + } + }, + cb + ); return loader; - } - , loadcss: function (url, cb) { + }, + loadcss: function (url, cb) { var parts = urlParse(url); url = parts.u; - loaded[url] || appendElmt('link', { type: 'text/css', rel: 'stylesheet', href: url, id: parts.i }); + loaded[url] || + appendElmt('link', { + type: 'text/css', + rel: 'stylesheet', + href: url, + id: parts.i + }); loaded[url] = true; cb && cb(); return loader; - } - , load: function () { - var argv = arguments, argc = argv[length]; + }, + load: function () { + var argv = arguments, + argc = argv[length]; if (argc === 1 && isA(argv[0], Function)) { argv[0](); return loader; } - load(loader, argv[0], argc <= 1 ? undefined : function () { loader.load.apply(loader, [].slice.call(argv, 1)); }); - return loader; - } - , addAliases: function (_aliases) { - for (var i in _aliases) { - aliases[i] = isA(_aliases[i]) ? _aliases[i].slice(0) : _aliases[i]; - } + load( + loader, + argv[0], + argc <= 1 + ? undefined + : function () { + loader.load.apply(loader, [].slice.call(argv, 1)); + } + ); return loader; - } - , onError: function (cb) { + }, + onError: function (cb) { errorHandlers.push(cb); return loader; } - } - ; - if (checkLoaded) { - var i, l, links, url; - for (i = 0, l = scripts[length]; i < l; i++) { - (url = scripts[i].getAttribute('src')) && (loaded[url.replace(/#.*$/, '')] = true); - } - links = D[getElementsByTagName]('link'); - for (i = 0, l = links[length]; i < l; i++) { - (links[i].rel === 'stylesheet' || links[i].type === 'text/css') && (loaded[links[i].getAttribute('href').replace(/#.*$/, '')] = true); - } - } + }; //export ljs window.ljs = loader; // eval inside tag code if any } - // eval script tag content if needed - scriptTag.src && script && appendElmt(scriptStr, { innerHTML: script }); })(window);