Custom Code
With Custom Code your plugin can install code snippets in a user's Website via <script>
tags. This can be used to load external scripts on a site. Custom code should be valid HTML.
Inserting custom code
The example above inserts a <script>
tag at the end of the <body>
tag in the resulting HTML.
The location
property has the following values:
headStart
- Injects the code snippet at the start of the HTML<head>
tagheadEnd
- Injects the code snippet at the end of the HTML<head>
tagbodyStart
- Injects the code snippet at the start of the<body>
tagbodyEnd
- injects the code snippet at the end of the<body>
tag
Clearing installed code snippets
Setting the html
value back to null
clears the installed code snippet.
Reading Custom Code
Your plugin has the ability to detect if custom code was set by your plugin. Users also have the ability to disable custom code inserted by your plugin. When users disabled your Custom Code snippet, your plugin does not have the ability to re-enable the custom code.
You can however detect whether or not custom code was installed correctly.
Subscribing to changes
If you want to update your UI when Custom Code is registered or when changes to the settings are made you can subscribe to changes.