I'm trying to figure out the best way to create a javascript widget that: - Can be embedded in most websites - It's self contained (initially only - Can be configured
An example of desired functionality would be Stripe's checkout widget: link
I'm not getting very lucky in finding resources, tutorial or best practices. From what I've seen so far the most common flow is:
- Initial self executed script is inserted in website
- The script reads the passed configuration and merges it with the default
- Html element that triggers the behaviour (e.g. button), and bound to a handler
- An iFrame is created passing the configuration and most of the logic happens
My current doubts are:
- Is there a recommended Webpack (or similar) template to create the initial script from ES6 project?
- Communication (both ways) between website and iframe
- Security concerns
Any input is welcome!