Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple instances on one page #7

Open
notslang opened this issue Dec 27, 2013 · 6 comments
Open

multiple instances on one page #7

notslang opened this issue Dec 27, 2013 · 6 comments

Comments

@notslang
Copy link

If I have the flying focus chrome plugin installed and I visit a site that uses the flying focus script, 2 instances of flying focus run on the same page. This creates 2 separate elements (both with the id flying-focus) and they are both animated.

The fact that this happens doesn't actually break anything (they just overlap), and it's not really a performance concern since it's such a light plugin. Rather, it simply feels wrong to have 2 of them running at the same time, especially since both of the elements created have the same id.

So, flying-focus should check if the #flying-focus element has already been created, and exit if it has, to prevent multiple instances.

@NV
Copy link
Owner

NV commented Dec 27, 2013

The extension used to check #flying-focus: flying-focus.jspp.js#L2. I removed when I implemented lazy initialization flying-focus.js#L32-L35, e.g. the flying-focus element gets created on first focus event. In this situation race conditions happen.

I haven’t seen any websites besides mine using the script so I don’t think it isn’t very important issue as for now.

@notslang
Copy link
Author

JS is inherently single-threaded, so one of the instances is bound to create the element first, right? Eh, anyway, you're right - it isn't a big issue.

@NV
Copy link
Owner

NV commented Dec 27, 2013

The problem is that flying-focus.js can be initialized either before or after the extension, depending on where script element is (head or end of the body).

@notslang
Copy link
Author

exactly, so whichever happens first gets to continue running, the other
just stops. it doesn't matter whether the extension or script is the one
that is running, it's just whichever is first.

On Fri, Dec 27, 2013 at 5:13 PM, Nikita Vasilyev
[email protected]:

The problem is that flying-focus.js can be initialized either before or
after the extension, depending on where script element is (head or end of
the body).


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-31284514
.

@nwinter
Copy link

nwinter commented Jan 2, 2014

CodeCombat is using it right now, and I see the issue. (I don't mind it at all; just adding an example of a site that uses it.)

@NV
Copy link
Owner

NV commented Jan 2, 2014

@slang800, that would work. I don’t have much time to test but I’ll accept a pull request.

@nwinter nice, I’m a fan! I just listed it on newly created In the Wild wiki page.

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

No branches or pull requests

3 participants