469,337 Members | 6,001 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

size of Javascript file

184 100+
Hi All,
Is there a max limit on the size of a Javascript file that can be used in web environment?

How can we set header/expires for a Javascript file alone (and not for the entire JSP,HTML, etc).

please correct me if i'm wrong.. do needfull.
Thanks.
Jan 23 '09 #1
13 5336
acoder
16,027 Expert Mod 8TB
What size are we talking about here? What problem does it cause?

You can set headers if you use JSP to generate the JavaScript file and include like this:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="includes/js.jsp"></script>
Jan 23 '09 #2
gaya3
184 100+
@acoder

Hi Acoder,
1. since my application has 80 -90 javascript files to load,it causes performance issue.hence i started combining the javascript files.And thus, is there any limit for maximum size of javascript in web environment?
2. yes Acoder ,ofcourse,what u said is rite for header/expires.But my query is very close to javascript. for jsp we can set header/expires.. But for me header/expires need to be set only static content (javascript).

Hope u got my query?
Jan 23 '09 #3
gits
5,390 Expert Mod 4TB
to reduce the filesize of JavaScript(s) you may use a 'minifyier', which just drops useless whitespaces etc. ... in you productive version of the script-file(s). have a look here to get the basic idea of it.

kind regards
Jan 23 '09 #4
acoder
16,027 Expert Mod 8TB
That is a lot of files. Are you sure you need that many? The limit depends on the browser and the system. Also, note that once you include a file using script tags, it can be cached, so page load the second time round should be faster.
Jan 23 '09 #5
gaya3
184 100+
@acoder
Acoder,
yeah!... Acoder.. ofcourse, time taken to load the second round should be less , because of caching. Eventhough it cached the request for the javascript files in web server is received.. and hence again causing the time delay (performance issue) to load the page.
Jan 23 '09 #6
gaya3
184 100+
@gits
Gits,
Thanks for your inputs.. is there any other way to reduce the file size other than using tools like JSmin etc... And more is , from your refrence link
i found the below comment
"you should use a build script to reduce the size of JavaScript and CSS before every deployment stripping comments and whitespace"..

what does build script means?
Jan 23 '09 #7
gits
5,390 Expert Mod 4TB
@gaya3
of course ... you could do it manually ... ;) ... and/or use the gzip-compression (when your webserver is able to do so) ... have a look here

@gaya3
this is a script that just starts to minify the files when you want to deploy it to the productive machine ... so you don't need to minify your dev-version so that you could easyly work with them ... and while this is not required in the production version every comment etc. could be dropped before releasing the files to production

kind regards
Jan 23 '09 #8
gaya3
184 100+
Gits,
Thanks for your inputs... From the link you suggested, i found the below comment...
"For static components: implement "Never expire" policy by setting far future Expires header "
How do i set the expires for static components... pl provide me some samples for javascript....
Jan 24 '09 #9
gaya3
184 100+
@gits
Gits,
As mentioned in the refrenced link... where do i suppose to add the
below comments in my application.. in header?
" Accept-Encoding: gzip, deflate
Content-Encoding: gzip"
if so please provide me some samples....
Does Gzipping reduces the response size by about 70% ? really?
will the time taken to download the javascript file get reduce?
Jan 24 '09 #10
gits
5,390 Expert Mod 4TB
i think both of it has to be done through the Apache configuration ... may be this link does help you?

kind regards
Jan 25 '09 #11
gaya3
184 100+
Ho ! ok Gits.. could you please say me how to add "Never expires" for the static components (javascript files) in headers.
Jan 27 '09 #12
gits
5,390 Expert Mod 4TB
hi ... i'm not an Apache expert ... and as i said i think it is a webserver configuration issue ... may be you should ask in the corresponding forum which depends on the webserver you use ...

kind regards
Jan 27 '09 #13
Dormilich
8,651 Expert Mod 8TB
@gaya3
if you have Apache and the mod_headers module installed, have a look at the above mentioned link. otherwise you may try the ExpiresByType directive
Jan 27 '09 #14

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by vishal | last post: by
35 posts views Thread by munish.nr | last post: by
3 posts views Thread by Angel | last post: by
24 posts views Thread by gizoto316 | last post: by
5 posts views Thread by josh.tucholski | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.