Reputation: 43
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
Upvotes: 3
Views: 152
Reputation: 1675
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.
Upvotes: 1