Results 1 to 3 of 3

Thread: loading css after javascript?

  1. #1
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default loading css after javascript?

    hi,

    is it possible to load css after javascript and the body?

    Reading on:

    i am developing a website that uses javascript to figure out the browser size, it then changes the stylesheet (and the images) accordingly. now for this to work the javascript must be loaded after the body and this works fine.

    however this means that the default stylesheet loads first, which results with two lots of css (and images) loading making the website inefficient. to get around this problem i need to load the css after javascript has had time to choose the right stylesheet. i dont want to set the default template as empty because people without javascript will get no styling. i was thinking maybe inline javascript loads before css?

    any ideas?

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Have you tried to use the onload event?

    It will fire when your page has loaded, which would indicate that your CSS has fully loaded:
    Code:
    <script>
    window.onload=function()
    	{
    	if(document.getElementsByTagName('link')[0]) // Check for the first link element <link rel...
    		alert('First stylesheet already loaded');
    	}
    </script>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •