Skip to content

Commit

Permalink
support adding a script id attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
voutilad committed Feb 15, 2019
1 parent c2418da commit ce5fa19
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/async-script-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function makeAsyncScript(getScriptURL, options) {
componentDidMount() {
const scriptURL = this.setupScriptURL();
const key = this.asyncScriptLoaderGetScriptLoaderID();
const { globalName, callbackName } = options;
const { globalName, callbackName, scriptId } = options;

// check if global object already attached to window
if (globalName && typeof window[globalName] !== "undefined") {
Expand Down Expand Up @@ -94,6 +94,9 @@ export default function makeAsyncScript(getScriptURL, options) {

script.src = scriptURL;
script.async = true;
if (scriptId) {
script.id = scriptId;
}

let callObserverFuncAndRemoveObserver = func => {
if (SCRIPT_MAP[scriptURL]) {
Expand Down

0 comments on commit ce5fa19

Please sign in to comment.