Issue 1277Under Construction!
Background
Sometimes, complex gadgets may want to load code incrementally and have that code be available to all new and existing views of a gadget without having to re-parse the needed code each time a view renders. Giving a gadget an execution scope in which to load script can significantly improve performance of a complex gadget, or any gadget that opens views frequently.
This would also apply to the incremental loading of other resources.
It should be noted that setting up an alternate channel for eventing is strongly discouraged here, even though it would be possible. The end result would likely be a degradation of user experience in the container in the long run. If eventing APIs are seen as insufficient, it would be better to get involved and make your concerns heard rather than work around the problem permanently.
Details
To use this feature, a gadget must require(or optional) the feature like so:
Code Block | ||||
---|---|---|---|---|
| ||||
<Optional feature="shared-script-frame"> <Param name="view">script</Param> </Optional> |
Gadgets MUST specify a param named "view" that indicates which gadget view should be rendered as the script frame. This specified view will render hidden on the page.
...
Gadgets can request a reference to the shared script frame:
Code Block | ||||
---|---|---|---|---|
| ||||
gadgets.util.registerOnLoadHandler(function() { gadgets.script.getScriptFrame(function(scriptFrame) { // Do something with the script frame here. }; }); |