Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Deferred Javascript download

    I know that the showcase displays a progress screen while all the javascript files are downloaded and then starts the GWT app.

    What I need to do is start the GWT app and then download the javascript, as the SmartGWT libraries are not required by my home page.

    Following recommendations from Page Speed I have got the javacript loading after my homepage is showing but calling load_skins after the page has loaded ends up doing a document.write while loading skin_styles.css and kills my app

    I have deferred the download by including the following script in my html

    <script type="text/javascript">

    // Add a script element as a child of the body
    function downloadJSAtOnload() {
    var isomorphicDir = "sc/"
    var core = document.createElement("script");
    core.src = "sc/modules/ISC_Core.js";
    document.body.appendChild(core);
    var foundation = document.createElement("script");
    foundation.src = "sc/modules/ISC_Foundation.js";
    document.body.appendChild(foundation);
    var containers = document.createElement("script");
    containers.src = "sc/modules/ISC_Containers.js";
    document.body.appendChild(containers);
    var grids = document.createElement("script");
    grids.src = "sc/modules/ISC_Grids.js";
    document.body.appendChild(grids);
    var forms = document.createElement("script");
    forms.src = "sc/modules/ISC_Forms.js";
    document.body.appendChild(forms);
    var calendar = document.createElement("script");
    calendar.src = "sc/modules/ISC_Calendar.js";
    document.body.appendChild(calendar);
    var binding = document.createElement("script");
    binding.src = "sc/modules/ISC_DataBinding.js";
    document.body.appendChild(binding);
    var load_skin = document.createElement("script");
    load_skin.src = "js/load_skin.js";
    document.body.appendChild(load_skin);
    }

    // Check for browser support of event handling capability
    if (window.addEventListener)
    window.addEventListener("load", downloadJSAtOnload, false);
    else if (window.attachEvent)
    window.attachEvent("onload", downloadJSAtOnload);
    else window.onload = downloadJSAtOnload;

    </script>

    If I download skin_styles.css by including it in my gwt.xml file and comment out the line

    isc.Page.loadStyleSheet("css/skin_styles.css", theWindow)

    in load_skins, the app loads but when I navigate to the page that contains SmartGWT components the window titles are not sized properly and the data binding doesn't work.

    Any pointers would be much appreciated.

    #2
    Thanks, very helpful

    Comment

    Working...
    X