On the serverside, the sanitized html and the javascript can be gotten separately after the cajoler is done with compiler.getStaticHtml() and compiler.getJavascript(). You can render the static html initially and execute the js later as part of your onfocus handler.
One suggestion make this work nicely - by default, caja renders the css with javascript because the cajoler doesn't know if there is going to be more than one cajoled snippet in the page and if so, what it's ids are. If you're generating the entire page, this is something you know and pass that information on the cajoler. To do so, call pluginMeta.setIdClass(...unique name for each content you're rendering...) for each piece of content that you render and that will allow more of the css to show up statically. That'll mean the page looks much nicer even before the js starts executing. Depending on your site, the unique name for each content might be based on the url from which you fetched the content, just a incrementing counter or preferably something based on the hash of the content etc. On Thu, Jul 5, 2012 at 10:30 AM, Doug Koellmer <[email protected]> wrote: > Hello, > > For my app, a user's sandbox has two states...I'll call them focused and > unfocused. While unfocused, my rough goal is to display content in their > sandbox as if the browser had scripting disabled, maybe even supporting the > noscript tag so that users could create a kind of "splash"/summary/icon > -type of view. When the sandbox is clicked, it becomes focused, at which > point I'd like javascript to become enabled. > > The obvious way to do this that I can figure out is to compile two > versions of a user's source on the server, one with, one without, scripting > enabled (which I'm assuming is easily doable, correct if wrong). My app > would simply download the <noscript> version initially, and only download > the scripted version if needed. > > Does this sound like a good approach? The other scheme I can think of is > compiling just one full version, and somehow having caja on the client > render the compiled html as if scripting were enabled or disabled, but I > don't know if that's possible. > > In fact, I kind of like the first approach because it probably means much > less network overhead (assuming <noscript> content is comparatively very > small) if a user of my app is scrolling through dozens of profiles and only > focusing a given profile once in a while. > > Anyway, sorry for rambling...thanks again for any input. > > - Doug >
