| Page 1 of 1 | [ 4 posts ] |
|
hi,
I am new to javascript world, still a learner. in my project, there is yui library and some custom js files. i use min version of yui files, i am thinking if custom js files are to be minified? i understand that js files are cached, server trip is made first time and then file is cached on browser. if file is cahced after first trip, then why need for minifier. what advantage do minifiying add? thank you in advance. |
|
Welcome to JavaScript!
It's true that JS files are typically cached after the first time they're requested, but uncached requests still have to download the file. Browser caches are limited in size and are sometimes cleared, so cached files don't stay cached indefinitely. Minifying JS ensures that all files are as small as possible, so that even an uncached request is as fast as it can be. Minification is especially important for mobile browsers, most of which don't have persistent caches (they only cache things in temporary memory, which is wiped when you exit the app). Mobile browsers are both more likely to have unprimed caches and more likely to be on slow or high-latency connections. |
|
thank you ryan for helping.
but i cannot work on minified file. i work on normal javascript file and before copying to prod i update html file to refer to min js file? i see yui having dynamic loading of js file, even that to be changed to load min version before prod? is there a tool that changes refer to min version file name in html and js file? or i have to do it manuually. Sorry, my question might look silly. |
|
It's definitely not a good idea to try to edit minified files. The best way to manage this is to use a build tool of some kind so that you can work on raw files during development, and quickly convert them to minified files when you're ready to push them to production.
The YUI Builder can do this, but is probably too complicated for your needs. An easier solution might be to use a simple Makefile like the one described in this blog post: http://wonko.com/post/simple-makefile-t ... css-and-js |
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group