You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can import the plugin into your own JavaScript modules in a couple of ways.
28
28
29
-
The first way is using the native [`import` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) in JavaScript. Here you can assign any name you want to the function you are importing, and you only need to provide a path to the plugin's `index.js` file:
29
+
The first way is using the native [`import` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) in JavaScript. Here you can assign any name you want to the function you are importing, and you only need to provide a path to the plugin's `index.vanilla.js` file:
If you want to use `require` to load this plugin instead, and use a bundler like Webpack or Parcel, make sure to add `.default` as you require it:
35
+
You can also use `require` to load this plugin instead with a bundler like Webpack or Parcel:
36
36
37
37
```js
38
-
constjsincss=require('jsincss').default
38
+
constjsincss=require('jsincss')
39
39
```
40
40
41
41
Once you have imported this plugin into your module, you can use the plugin as `jsincss()`
42
42
43
43
## Using JS-in-CSS Stylesheets
44
44
45
-
The main goal of this plugin is to let people using a JS-in-CSS workflow load JIC stylesheets inside of a JavaScript module.
45
+
The main goal of this plugin is to let people using a JS-in-CSS workflow load [JIC stylesheets](https://responsive.style/theory/what-is-a-jic-stylesheet.html) inside of a JavaScript module.
The default `selector` is `window`, and the default list of `events` is `['load', 'resize', 'input', 'click']`.
58
58
59
+
You can also create and listen for custom events with JavaScript using `new Event()` and `dispatchEvent()` for total control over when jsincss reprocesses styles.
60
+
59
61
## Example
60
62
61
63
This example uses the default `selector` and `events` list, and provides the stylesheet inline.
0 commit comments