3

I am trying to implement a chat widget on a website. The chat code has to stay independent of the website. My goal is to make one JS that has everything and Wrap that inside a IIFE. So if someone wants to implement chat on their site he/she can just include one JS and thing would work .

and then user can do window.chat.serverName= Window.chat.start();

This would open a new page and the chat application would be on that

3
  • You can use various bundlers, like webpack or systemjs. Commented Oct 27, 2016 at 3:09
  • How did you end up doing it? What did you try, what worked best? Commented Feb 22, 2019 at 2:20
  • I used Webpack with various loaders like CSS and HTML. Webpack would bundle everything for you and spit out a JS file :) Commented Mar 3, 2019 at 2:26

1 Answer 1

1

Use webpack with css-loader and html-loader, and require your css files and html files from javascript. (e.g. const css = require('css/foo.css');)

My project is doing it.

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.