Search code examples
javascripticonsfont-awesomedocument-readyglyphicons

load font-icons before javascript


Is there an option to load / render icon-fonts (e.g. bootstrap glyphicons) before Javascript loads? I have the problem, that the icons will not be displayed until the ajax get requests are ready. In the meantime, the icons will be displayed as simpel squares.

I've got in my header all css related stuff and before the footer the js stuff to render first the layout and at the end javascript.

This is my basic get request:

$(document).ready(function () {
    // ajax stuff
    $:ajax({
        url: "/api/v1/data/point/" + id,
        type: 'GET',
        ( .. )
    })
}

Solution

  • You could use

        $(window).load(function() {
        //do stuff
    });
    

    to make your script do something only if the whole page is loaded/rendered. While document.ready fires as soon as the domtree is finished being created, window.load waits for the whole page including all assets to be loaded.