Defining JS Specific Data
JS specific data will execute on a specific file URL. To define JS specific data, follow the steps below:
1. Create a JS file
Create a JS file to store JS specific data.
/specific/intro.js
console.log("Hello ProposeJS");
2. Update the propose.json file
Define a specific JS object where the key will be the specific file path of the HTML file, and the value will be an array of JS files for this HTML file.
/propose.json
{
"js": {
"specific": {
"/articles/intro.html": ["/specific/intro.js"]
}
}
}
Note
- JS specific data will execute only on a specific HTML file.
- JS specific data should use targetting HTML.
- You can execute multiple JS files for one HTML file.
- JS specific data will be removed from the webpage on state change.
How it works
JS specific data will execute only on a specific URL. ProposeJS checks if the URL matches the proposed URL, then executes the JS specific data. On state change, the JS specific data will be removed from the webpage.