Defining JS Common Data
JS Common Data executes on a particular directory. To define JS common data, follow the steps below:
1. Create a JS File
Create a JS file to store JS common data:
/article/common.jsconsole.log("Hello ProposeJS");
2. Update the propose.json File
Make a proposal for JS common data in the propose.json file:
/propose.json{
"js": {
"common": {
"/article": ["/article/common.js"]
}
}
}
Note
- JS common data will execute on the particular directory mentioned in
/propose.json. - JS common data should use targetting HTML common content
- JS common data will execute if the directory matches with the mentioned directory in
/propose.json. If the previous directory and the recent directory are the same, then JS common data will also execute else if directory change js common data will not execute. JS common data will execute on load and state change events.