Skip to content

Run queued functions after script is loaded and set to window - #31

Merged
djih merged 1 commit into
masterfrom
fix_init_proxy_queue
Oct 1, 2015
Merged

djih merged 1 commit into
masterfrom
fix_init_proxy_queue

Conversation

@djih

@djih djih commented Sep 30, 2015

Copy link
Copy Markdown
Member

In index we transfer the proxy function queue into the real amplitude object, and then in the snippet added a script load callback that runs the queued functions from within the amplitude object. This guarantees that the real amplitude object is set in window.amplitude, allowing init callbacks to access amplitude properties and options.

Comment thread src/amplitude-snippet.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the browser compatibility of this function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome and Firefox definitely support it. It's part of the HTML 4.01 standard, and seeing as how IE9 has HTML5, it should be okay: http://www.w3schools.com/tags/ev_onload.asp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok confirmed IE9 support for onload via my own virtualbox running IE9

@curtisliu

Copy link
Copy Markdown
Member

LGTM

djih added a commit that referenced this pull request Oct 1, 2015
Run queued functions after script is loaded and set to window
@djih
djih merged commit c2db52e into master Oct 1, 2015
@djih
djih deleted the fix_init_proxy_queue branch October 1, 2015 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants