Re: GWT defer … - possibility for plugins?

mike thompson mithomps at redhat.com
Mon Apr 22 14:02:24 UTC 2013


On Apr 22, 2013, at 3:01 AM, Jiri Kremser <jkremser at redhat.com> wrote:

> Hi,
>  Mike's commit moved all the dependencies on external JS libraries from CoreGUI.gwt.xml to CoreGUI.html. Then, in the plain old html, he added the "deffer" attribute [1] to all the scripts to make the browser to download them after the actual page is rendered (here is the load time saving).
I agree this 'defer' attribute is *not* what we want for plugins. Here is a description of 'defer' and its brother 'async':

async allows the script to be downloaded in the background without blocking. Then, the moment it finishes downloading, rendering is blocked and that script executes. Render resumes when the script has executed.

defer does the same thing, except it guarantees that scripts execute in the order they were specified on the page. So, some scripts may finish downloading then sit and wait for scripts that downloaded later but appeared before them.

Note: async is newer and not supported by as many browsers:
http://caniuse.com/#search=async


> 
> JavaScript can be dynamically loaded by DOM manipulation [2] based on some inapp logic. Once a script loaded it should override all the functions with the same name that have been already defined in other scripts. This overriding can actually do the thing you've described (selecting a script from some combobox).
There are several ways of doing dynamic loading. GWT even provides a ScriptInjector to dynamically load javascript at runtime:
 http://c.gwt-examples.com/home/ui/javascriptinjection

> 
> This could easily change the behavior of some JS methods that are already used by RHQ (those defined for jquery, d3, sparkline, or even the ones generated by GWT from Java). But I think this is not very suitable for adding some new functionality, because it would require to call the JS via JSNI from GWT.
Dynamic module loading/unloading is a common thing in the javascript world and there are several loaders: http://addyosmani.com/writing-modular-js/

> 
> btw. this is actually something between a feature and attack to applications written in JS called function hijacking, so I wouldn't wonder if it is prohibited by browsers in the future.
> 
> 
> [1] http://www.w3schools.com/tags/att_script_defer.asp
> [2] http://stackoverflow.com/a/12096099/1594980
> 
> jk
> 
> ----- Original Message -----
>> From: "Heiko W.Rupp" <hrupp at redhat.com>
>> To: "rhq-devel" <rhq-devel at lists.fedorahosted.org>
>> Sent: Monday, April 22, 2013 10:32:28 AM
>> Subject: GWT defer … - possibility for plugins?
>> 
>> Hi Mike, Jirka,
>> 
>> I saw this commit
>> 
>>> commit e4ac4b1b628ae5e577510045ead7967a603d4c1c
>>>   UI Performance - Move non-essential javascripts (like charting) out of
>>>   CoreGUI.gwt.xml to CoreGUI.html and add the 'defer' script eva
>> 
>> Could that mechanism also allow UI plugins - in the sense that e.g. those
>> plugins all implement some
>> "java script interface" and we sort of loop over the .html files that
>> implement them and e.g. populate a menu entry
>> with that?
>> I guess that they still need to be added to the root gwt.xml file at compile
>> time?
>> 
>>  Heiko
>> 
>> 
>> 
>> _______________________________________________
>> rhq-devel mailing list
>> rhq-devel at lists.fedorahosted.org
>> https://lists.fedorahosted.org/mailman/listinfo/rhq-devel
>> 
> _______________________________________________
> rhq-devel mailing list
> rhq-devel at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/rhq-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/rhq-devel/attachments/20130422/d46e54b4/attachment.html>


More information about the rhq-devel mailing list