Jump to content

Poor Library Design? App Is Running Really Slowly!


kael.shipman

Recommended Posts

Hey,

 

I built a javascript library (which is not so much a well-structured library as it is a jumble of functions that work together on an editor page), and it's gotten to the point where I click a button and it takes 2 seconds for the onclick to fire, and sometimes as much as 4 seconds for the chain of functions to complete. The button doesn't even attain focus til then. Very annoying.

 

Anyway, I'm kind of thinking that it's because of the way I've got my library structured (which, as mentioned, is not at all). In trying to build for forward compatibility with possible future AJAX needs, I've put the functions for each page into an object that I've called simply pageLib. Every function on the page is prefixed by "pageLib.". On top of that, I have a prodLib which is refeshed using new database information every time a new product is clicked in the dropdown menu (the application is a product editor for an online catalog). There are also about 10 global functions running from the index.js script.

 

The breakdown is as follows:

pageLib has about 10 object variables and 52 object functions

prodLib is composed of a few fairly large multidimensional arrays

the global scope has no variables and about 10 functions

 

When the user enters the page, the global functions and the pageLib functions and variables load immediately. When the user clicks the select box (that's all he can do at this point), prodLib is called from the database and loaded. When prodLib is loaded (as checked by the availability of a variable declared at the end of prodLib), pageLib begins a series of populating functions. The user then sees the product pane and is allowed to exercise a number of other pageLib functions to manipulate the data. When he's done, the script submits the data to the server and the user can select another product. When he does, the variables are refreshed to their default states and the manipulated html structure is restored to it's original state, then the process begins again.

 

My question (after so much meandering) is this: Is there any way - be it through better code, better structure, whatever - that I can get this script to respond and run faster, or should I just count on any script being slow when it has to handle as many as 70 functions on a page?

 

Thanks for the help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.