Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:09:57+00:00 2026-05-28T03:09:57+00:00

So in my page I have some little scripts which I dont really need

  • 0

So in my page I have some little scripts which I dont really need to load once you visit the site and in fact the user might not need them at all in their entire session.

Also, according to this: http://code.google.com/speed/page-speed/docs/payload.html#DeferLoadingJS its not a good practise either.

So for example, currently I have everything in ‘When dom ready’:

$(function() {
 // most of the code of which is not needed
});

If I dont place the code inside the Dom ready, its not executable at most of the times. So I thought of doing seperate functions for each snippet.

For exmaple:

function snippet1() {
   // Code here
}

and then when I need that snippet, I load it when needed with mouseclick. (Not always a mouselcick, depends what I need to load).

For example:

$('#button1').click(function() {
  snippet1();
});

So my question is: Is this the way of loading functions async so you reduce the page load time or is there a better way? I havent read this anywhere my examples, I just thought of it.

Note that I am aware of the asynch loading’s but that is not my option here, since I could combine all the functions in just one js file which will be cached, so page load time will be less than loading every time asynch js files.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:09:58+00:00Added an answer on May 28, 2026 at 3:09 am

    You’re mixing several things:

    1. Page load time
    2. JavaScript parsing time – After the script is loaded, it has to be parsed (error checking, compiling to byte code, etc)
    3. Function execution time

    You can’t do much about the page load time since you don’t want to split the script. You may consider to split it into two parts: One which you always need and an “optional” part which is rarely needed. Load the rare functions in the background.

    Note that page load times become pretty moot after the site has been visited once and you’ve made sure the browser can cache the files.

    If you want to reduce parse times, you have two options:

    1. Don’t load parts that you don’t need.
    2. Compress the scripts. Google has a great tool for that: the Closure Compiler. Besides making your scripts faster, it will also check for many common mistakes.

    The last part is the execution times. These are only relevant if the functions are called at all and when they do a lot. In your case, I guess you can ignore this point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a little preliminary pointing at the right direction. I have a web page
I need to have a Python CGI script do some stuff (a little bit
I have some javascript which will create some sort of widget on a page.
I have a php page and i have some javascript code to have a
I have some the page elements split into separate visual blocks. I am currently
I have some script in my default page that redirects users to language specific
I have some textboxes on a page and I want to click a link
I have some CRUD routing: /news/{page} // public /news/new // private /news/{slug}/show //public /news/{slug}/edit
I have some jquery/php interaction set up on a page. It submits some data
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.