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

Is there a way to conditionally load harmony-reflect #73

Open
mschipperheyn opened this issue May 10, 2016 · 2 comments
Open

Is there a way to conditionally load harmony-reflect #73

mschipperheyn opened this issue May 10, 2016 · 2 comments

Comments

@mschipperheyn
Copy link

What is the best to avoid including harmony-reflect by default. It's quite big and it would be nice if the library would not be loaded if the client already supports the required level of Proxy functionality?

@tvcutsem
Copy link
Owner

I'm not sure what the best approach is to this kind of problem (not loading a polyfill if the platform already supports it). Right now the library is smart enough not to patch the Proxy object if it is already conforming, but obviously the code necessary to patch it must be shipped regardless.

I try to keep reflect.js as free from external module loading dependencies as possible, so that it works unchanged in both the browser and node. I'm not sure how to do conditional loading in a platform-independent way.

Given that you're worried about code size, I assume you're mostly interested in using reflect.js in the browser. In that case it's always possible to conditionally load reflect.js based on a test such as if (typeof Reflect === undefined || typeof Proxy === undefined || typeof Proxy !== "function") { /* dynamically load <script src="reflect.js"/> */ }. Would that be sufficient or were you looking for a different kind of solution?

@mschipperheyn
Copy link
Author

That makes sense. I work in a non browser environment but this approach should work also

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

2 participants