Deploying my site, lots of small script files. Long loading time [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've built a web application.
In my application I have many javascript and css files .
They are separated based on my application's logic.
I am talking about close to 20 of these files (each file is 2 kb +-).
They seem to take quite a while to download (6 - 10 seconds altogether).
What would you do to cut down the download time? Are there any best practices in this field?
Thank you

Join all JavaScript and all CSS files into one big JS and one big CSS file, and minify them.

You can compress your file by removing spaces, use short variable names, etc. Try looking for tools that are around for that purpose. Also, you can add all scripting to one file so that only one files needs to be downloaded and you can introduce some caching mechanism to prevent downloading the script over and over again.

http://rakaz.nl/2006/12/make-your-pages-load-faster-by-combining-and-compressing-javascript-and-css-files.html
[http://driven-monkey.com/?p=97]
check these out

Related

When should I save Javascript code into different files or the same file? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am a beginner of Javascript. I have done some Python and Java before.
I am not clear when and why we should store codes into different .js files or the same file.
Is there any conventions and rules for this?
Well, the main reason of javascript code into different folders is for organization.
Similar to Java or Python, or any language, you should organize your code in different files to get a code that any other in your team can read easily.
But in production scope, or better said, in your website, it's a best practice to reduce the number os javascript files for performance reasons. If you have 2 javascript files, the server will send 2 request. In the case that you have 10 or 15 files, the web will have performance problems.
So, in development it's important to have multiple files to organice your code, but in production you can minify then into one. Uglify is a good tool to monify your code into one file.
Hope it helps.

add image CSS : local file or url? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am working on a HTML Webpage with CSS and Ajax. I would like to add an image and I know I can do it by adding the image in a folder inside my project or add it with an URL so which one is better method to use, I mean what should be the inconvinients of each method that would make me prefer one to the other ?
You should have it in a local file because:
1) Relative paths;
2) You have more control on it (what if the other site is down?);
3) You don't have to read 1000+ pages of terms of use in which the external website may say that they will own your images if you put them there.
You should use external hosting because:
1) It is cheaper (sometimes free);
2) You can free up bandwidth (especially if you have a lot of images);
3) Using relative paths is not always better (and can cause issues with migrations, see the comment)
Deciding which one you would use depends on your needs. If you have few images, it is better to store them locally. If you have a lot of images and don't have the resources to host them, it is better to use external services.

The better way to maintain css, js, font-cion, image's versions? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have few css files for a site and some css properties are shared through all of them. Plus there are also few js files. font icons file and images that I constantly updating. Whenever I tried to push to main repository, i had to make sure each file version are bumped using "?=number". I am seriously tired of doing this.
Is there a better way to do URL version bumps all together? Any help would be appreciated.
Additional info: I am using IIS7/8 and developing in windows system by using HG Mercurial. Back end uses asp.net visual basic, mysql.
Since you're using ASP.NET, your .NET devs can set a variable that holds a common increment number that you can use as the number in the ?v=number part. So, you just change all of your CSS/JS files to consume the variable one time only. For example:
string version = ConfigurationManager.AppSettings["VersionNumber"];
If you're using bundling, there is a better answer here:
How to make bundles unminify and list individual files when using a cookieless static content server?

What js/css files should I bundle? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am looking into the bundling features of ASP.NET 4.0 and am just curious what rules/practices people follow when deciding which files to bundle?
Should I group things by what they are, like put all jQuery files together or is it a good idea just to bundle up all files that are used in the same place?
I recommend reading this tutorial on bundling and minification
bundling and minification
Personally, I like to have one css bundle and one js bundle per page. Each bundle will only contain the files needed for that page. Keeps the http requests and size down.
I think how to bundle your files can be largely subjective. The only thing I think most everyone would agree upon, is you should organize your files once you have more than just a few.
If you are working on a simple site and you only have a few JS files and one CSS file, I don't see a problem with putting them all in the same place.
Once you get multiple files I like to at least group them by type:
/lib/css
/lib/js

How long JavaScript file can be in practice? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I know this must be a silly question, but when those who create web browsers implement JavaScript and other parts, they should have some number in their mind, how big they expect the JavaScript file to be practically?
Of course modularity is good, but sometimes you just need something big. Especially machine-generated. And single file is seemingly faster to download and probably have a longer live in cache.
Some of my programs in other languages grow over 30K lines in single file, and I used to think that JavaScript is just about tiny files to handle onClicks. But now as big companies create huge apps, like spreadsheets or image editors, I wander how big the single file could be. What limits the size?
there is actually no file size limit besides from your own computer resources
As I know there isn't any limit to it.
The only limit is how much your CPU / RAM can handle?

Categories

Resources