1

Let's say I have component C defined in script S1. Now, on a different page of my web-app, I want to display an instance of C in script S2 without having to redefine C in S2. How can I accomplish this?

1 Answer 1

1

Two choices:

1) Assign C to some global window property, load the script S1 first and access it with window.C from script S2. This works in simple cases but is a bit messy.

2) Use a module bundler like webpack. It comes with many configuration options but basically solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.