Reputation: 1921
I created webpage which has JavaScript in single file but the size is very high. When I run the page, the loading time of JavaScript is very high in Chrome. FYI: The script file created from excel tool which has lot of hidden fields and scripts but everything needed to make application worked.
Have you anyone gone through same thing and what is the solution we can make for this? Thanks in Advance.
Upvotes: 0
Views: 5078
Reputation: 5662
You should determine what´s taking time. Both FF and Chrome has a feature that shows the network traffic. Have a look at yslow as well, they have a great addon to Firebug.
Upvotes: 1
Reputation: 8104
Chome's auditing tools can tell you a lot about why is this happening, you should probably include more information about:
anyway even without all that, here's a checklist to improve performance for you:
http://example.com/blah.js
-> http://cdn2.example.com/blah.js
</body>
Upvotes: 1
Reputation: 19273
There are a couple of things you could do:
- minify your scripts (e.g. with Google closure compiler)
- combine your scripts (reduces the number of requests)
- turn on gzip compression
- load your scripts at the end of your body tag
- use a CDN, prevents loading your scripts all from the same location (most browsers will only load 2 files simultaneously from the same location)
Have a look at the YSlow plugin and Google PageSpeed, both very useful in improving performance.
Upvotes: 5
Reputation: 30530
There is no 'generic' issue of slow loading in chrome. It will all be down to individual scripts.
You'll need to determine 1) Which script is causing the slow load by process of elimination and then 2) Which part of the script is loading slowly, then you can take remedial action.
This could include minification or code refactoring.
Tools like fiddler2 will help you track this time, as you'll be able to view the indivdual page items load time.
Upvotes: 1
Reputation: 7579
Combine your scripts into as few files as possible, and minify them. Also load the scripts at the end of your page.
Upvotes: 1
Reputation: 37524
Run it through a script which combines and minifies it. There are plugins for most build systems now that do that. That's how we compress about 1.5mb of JavaScript into about 500kb during our build process.
Upvotes: 2