Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    ASP
    ASP is offline
    New Coder
    Join Date
    Jun 2003
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    External JavaScript Documents

    Greetings...

    In terms of file size, at what point does an external JS document become to burdensome to load? I'm considering to create separate external JS documents if this is problematic.

    Thanks for your feedback.


    Respectfully,

    ASP

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    It depends. If the script doesn't have any document.write clauses, and you add defer="defer" to the script element, you can let it be far larger than the rest of the document including images. The recommendation is that you keep an upper limit of between 100k and 200k per screen/document, and preferably down to 20k-40k for fast loading on modems and other low-speed connections.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    ASP
    ASP is offline
    New Coder
    Join Date
    Jun 2003
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    liorean,

    Thanks for your feedback. Based on your response, I'm in good shape. Nothing in the external JS file generates content; "defer" is false (by implication - I've not included that attribute in the 'script' tag). The file size presently is approximately 21K, and I do not see it growing much larger.

    This brings to mind another question, however, if I may. Again, relating file size, what do you feel is reasonable for an external style sheet?

    Thanks again, liorean.


    Respectfully,

    ASP

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, that depends. If your site is graphics heavy, 20-30k would not make much difference. If your page is slim, though, I'd try to keep it at 5k-10k. Some larger sites such as news portals etc. use 50k-100k stylesheets, but then have only one stylesheet to cover all pages on their site. It takes a lot time to load first time, but then you don't have to load it again, so it's faster consecutive times. It's a bit of a trade-off between first-time load for those using cache, and each-time load for those that don't.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    ASP
    ASP is offline
    New Coder
    Join Date
    Jun 2003
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    liorean,

    Thanks again.


    Respectfully,

    ASP


  •  

    Posting Permissions

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