Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

including jquery cdn??

i just went ot the jquery website to include it, it is giving me different options..uncompressed, minified, slim, slim minified...since i am using CDN i dont understand why i have so many options, do they not all do the same thing

2 Answers

from a functional standpoint, they should all give you access to jQuery in your application. slim removes some functions that aren't used very often. It will break your code if you've used them in your application.

The following are removed in jQuery slim:

  • jQuery.fn.extend
  • jquery.fn.load
  • jquery.each // Attach a bunch of functions for handling common AJAX events
  • jQuery.expr.filters.animated
  • ajax settings like jQuery.ajaxSettings.xhr, jQuery.ajaxPrefilter, jQuery.ajaxSetup, jQuery.ajaxPrefilter, jQuery.ajaxTransport, + jQuery.ajaxSetup
  • xml parsing like jQuery.parseXML,
  • animation effects like jQuery.easing, jQuery.Animation, jQuery.speed

The other options represent different optimization techniques to improve your website's performance.

minified code has things like spaces removed, and variable names shortened. It's nearly impossible to work with, but decreases the file size, making it easier to send over the internet. However the resulting file is still a syntactically correct javascript file.

compressed means that the file has actually been compress (zipped) and must be extracted (usually by the browser) before being run. It also decreases the file size, making it easier to send over the internet.

I will generally go for the minified version, because it's optimised, but won't affect how you use JQuery in your own js files. It is the minified version of scripts I tend to see used as well. But as Samuel says, there are different choices in this respect, so can come down to choice when looking at what works better for you.