Libraries



Libraries

0 0


libraries

Slides for libraries in Unclass

On Github TylerFisher / libraries

Libraries

Tyler Fisher | @tylrfishr

What's a library?

Just some JavaScript someone else wrote that makes your life easier.

How do you use a library?

ProTip #1: Always use the minified version.

ProTip #2: Inherit your dependencies properly.

Order of inheritance

jQuery jQuery plugins (if any) Other libraries (underscore, d3, etc) Your custom JavaScript

ProTip #3: Read the docs!

When do you use a library?

Not Invented Here

vs.

Reinventing the Wheel

Sometimes, libraries are too complex.

Story time!

We started with a library called Fluidbox.

Fluidbox had a lot of code and functionality we weren't using. And it was buggy.

So we built our own lightbox.

Pros

Much less code

Does what we need it to

Not buggy

Cons

Development time

Not as well tested

Hard to add functionality

But...

To achieve the slide approach, we used a library.

We tried building our own, but it took too much time.

Instead, we altered the code to fit our needs.

Pros

Took less time

Supported experiments

Cons

Had to fix bugs

Overriding functionality

So what do you do?

Ask these questions

Does the library solve all of your needs? How well does the library work? How hard would it be to develop your own version of the library?

Suggestions for libraries

jQuery

Always use jQuery.

jquery.com

Underscore

Use Underscore for manipulating arrays and objects.

underscorejs.org

Bootstrap

Bootstrap's JavaScript has some nice functionality, such as Scrollspy.

getbootstrap.com

d3.js

d3.js is the best data visualization tool around. However, it's super hard to use.

d3js.org

Highcharts

Highcharts is an easier, though less flexible, charting library.

highcharts.com

Leaflet

Use Leaflet instead of Google Maps for map-based data.

leafletjs.com

FitVids

Use FitVids to make your video embeds play nice with responsive designs.

fitvidsjs.com

Unveil

If you have a long page with a lot of images, Unveil will let you "lazy-load" those images.

github.com/luis-almeida/unveil

Spreadsheets

Come see me. There's a workshop later.

tylerjfisher.com/libraries