Closed
Description
Current Situation
Currently the script tag always expects scripts to be structured as a effect hook...
// this is run on every render
() => {
// this is run once the script is loaded and each time its content changes
return () => {
// this is run when the script is unloaded (i.e. it's removed from the tree) or just before its content changes
}
}
Proposed Actions
The script tag should behave as a normal script by default
Utilize one of the following designs
- A parameter to utilize a destructor.
- It could possibly be a kwarg called
destructor="..."
, which is the name of a JavaScript function within this script's scope that will be called on unload - Alternatively, could be a boolean flag such as
returns_destructor
to denote the script is a singleton function with a destructor
- It could possibly be a kwarg called
- Instead of assuming the script is like an effect, we should be able to check if the script evals to a function, and if it does, we'll call it like an effect
Work Items
- Develop a method to create normal scripts
- Consider adding support for a
src=...
tag, if it does not exist