admin管理员组

文章数量:1406140

This one should be easy, and I think I know the right answer, but here goes.

For patibility reasons, should I leave the filename of jQuery as "jquery-1.3.2.min.js" or just rename it to jquery.js?

My guess is leave it as is to avoid conflicts in case another app uses a different version of jQuery. If they've renamed it to "jquery.js" and I do the same, I see potential version conflicts.

Am I wrong or way off base?

Jeff

This one should be easy, and I think I know the right answer, but here goes.

For patibility reasons, should I leave the filename of jQuery as "jquery-1.3.2.min.js" or just rename it to jquery.js?

My guess is leave it as is to avoid conflicts in case another app uses a different version of jQuery. If they've renamed it to "jquery.js" and I do the same, I see potential version conflicts.

Am I wrong or way off base?

Jeff

Share Improve this question edited Sep 17, 2009 at 16:09 Michael Paulukonis 9,1115 gold badges51 silver badges68 bronze badges asked Sep 17, 2009 at 15:50 JeffJeff 6215 silver badges21 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

It's a very good idea to have version-numbered JS (and CSS) files, because that lets you configure your web server to use a far-future Expires header on such files without running into caching problems. When the file gets updated, it gets a new version number, so the browser always fetches the new version, not the old cached one.

You should do this on your other JS and CSS files, too. You want this to be automated, not something you manage by hand. Your development work happens on unversioned files, and your versioning system creates versioned copies and works out the details of updating the references to the CSS and JS files in the HTML files to point to the versioned copies. This can be a bit of work, but well worth it when it es to speeding up your site. It took me about a day to set my system up. The improvement wasn't subtle.

I would go with jquery-1.3.2.min.js because it's more specific and you can immediately tell if you're reviewing this site in months to e, as well as avoiding any filename confliction in the future.

You shouldn't have any issues with updating, if you're relying on something like an include/template file for the javascript.

I prefer to leave the version in the file name because there are times when you are changing versions and this is very helpful. At a glance I can see which version I am using on any given webpage.

In my opinion, its just a personal preference. If you have version in your file name, It helps you easily identify which one you are using with out actually opening the file. It also provides an indirect way of clients downloading the new version file (as it is never cached). If you don't use the ext, upgrading to newer version is easy in coding perspective, but takes the pain of force downloading the new file by all users. Remended way to use jQuery in app is using the google's hosting..




  google.load("jquery", "1.3.2");
  google.setOnLoadCallback(function() {
    // Place init code here instead of $(document).ready()
  });


Why and how to use jQuery hosted on google

本文标签: javascriptjQuery file nameStack Overflow