Tuesday, May 23, 2017

Ajax Lesson

NOTE: This lesson uses jQuery as the interface for basic AJAX work. By no means is AJAX a product of jQuery and you do not need jQuery to utilize AJAX.

What Is Ajax

In 1999 Microsoft created a new update for IE5 that would dynamically update stories on particular Microsoft webpages. This technology was later adopted by the rest of the Browser collective. Jesse James Garrett, in 2005, coined the term AJAX which stood for Asycronous JavaScript And Xml. A year later it received its first W3C draft specification.

AJAX allowed webpages to continually request resources without the need to reload the entire webpage. This allowed users to stay on a webpage longer and interact with other various features of that page as the requests were made. The asynchronicity that this brought revolutionized the previous web era, where all dynamic changes required a complete trip to the server for a full refresh of the page with the new content based on the user's intent.

Using Ajax

Utilizing AJAX can be complicated even today as some versions of IE and other browsers still have a different mechanism to initiate the calls. Therefore it is recommended to use a library or application framework which comes with an AJAX service to make these requests.

Package Manager Best Practices

Bower

Use Bower for libraries that will be part of your deployed application. This would be things like the angular library, bootstrap and jquery.
These are all installed using the –save flag to make sure that your resources are defined as required for your project.

NPM

Use NPM for libraries that will be running in your development environment. Typescript Types, development tools and the like are things you should be using NPM for.
These are all installed using the –save-dev flag to make sure the NPM file represents your resources accordingly.

NuGet

Use NuGet to pull assembly only references for your dotnet application. This package manager is built into Visual Studio and is part of the build and development experience for dotnet applications.

JavaScript Module Loaders

Typescript supports most of the popular module systems for JavaScript.
These provide a similar functional process of asycronously loading your JS files without the need to create literal SCRIPT tags to bring the files in. The benefits here are listed thoughout posts all over the internet. Some of the benefits that fit a more scientific representation over the opinionations that are widespread:
  • Prevents unneeded files from loading into your applications/webpages
  • Creates a self encapsulating JavaScript loading process that unblocks your application(s) execution
  • Creates more maintainable code.

Should I check in my dependencies?

I was asked this week if it was better to check in dependency files such as jQuery and AngularJS into your git repo or to use a CDN. This has no one correct answer, however, there are things you should consider because of what it says about you as a developer.

Ajax Lesson

NOTE : This lesson uses jQuery as the interface for basic AJAX work. By no means is AJAX a product of jQuery and you do not need jQuery to ...