AngularJS Best Practices: Directory Structure

https://scotch.io/tutorials/angularjs-best-practices-directory-structure

 

We spend a lot of time writing code. In the early phases of a project, the directory structure doesn’t matter too much and many people tend to ignore best practices. In the short term, this allows the developer to code rapidly, but in the long term will affect code maintainability. AngularJS is still relatively new and developers are still figuring out what works and doesn’t. There are many great ways to structure an app and we’ll borrow some principles from existing mature frameworks but also do some things that are specific to Angular.

In this article, I will cover best practices regarding directory structures for both small and large AngularJS apps. This may be a hot button issue with some developers and while there is no “perfect” way to structure an app, I will be writing from experience and lessons learned from projects I’ve worked on.

#Standard Structure

First of all, let’s go over what not to do. Many AngularJS tutorials show an app structure that resembles the code below:


app/
----- controllers/
---------- mainController.js
---------- otherController.js
----- directives/
---------- mainDirective.js
---------- otherDirective.js
----- services/
---------- userService.js
---------- itemService.js
----- js/
---------- bootstrap.js
---------- jquery.js
----- app.js
views/
----- mainView.html
----- otherView.html
----- index.html

This is a very typical app structure that I see. On the surface, it seems to make a lot of sense and is very similar to a lot of MVC frameworks. We have a separation of concerns, controllers have their own folder, views have their own folder, external libraries have their own folder, etc.

The main problem with this directory structure is not apparent when you are working with only a handful of views and controllers. In fact, it is preferable to follow this approach when writing a tutorial for example or for smaller application. This structure makes it very easy for the reader to visualize and conceptualize the concepts you are covering.

This approach falls apart, however, when you start adding additional functionality to the app. Once you have more than 10 controllers, views and directives, you are going to have to do a lot of scrolling in your directory tree to find the required files.

For example, say you are building a blog with Angular. You decide that you would like to add the author information to the bottom of each article. Well now, you have to find the blog directive, controller, potentially the service and finally the view before you can even look at the whole picture and start making edits.

Learn Angular

Related Course

Say a few months down the line, you are adding additional features to your blog and want to rename a particular feature, again it’s a hunt throughout the directory structure to find the affected files, edit them, make sure they are all in sync, and then make the changes.

#A Better Structure and Foundation

Let’s get to best practices and what you should be doing to build scalable and maintainable AngularJS apps that your coworkers will love you for. An ideal AngularJS app structure should be modularized into very specific functions. We also want to take advantage of the wonderful AngularJS directives to further compartmentalize our apps. Take a look at a sample directory structure below:


app/
----- shared/   // acts as reusable components or partials of our site
---------- sidebar/
--------------- sidebarDirective.js
--------------- sidebarView.html
---------- article/
--------------- articleDirective.js
--------------- articleView.html
----- components/   // each component is treated as a mini Angular app
---------- home/
--------------- homeController.js
--------------- homeService.js
--------------- homeView.html
---------- blog/
--------------- blogController.js
--------------- blogService.js
--------------- blogView.html
----- app.module.js
----- app.routes.js
assets/
----- img/      // Images and icons for your app
----- css/      // All styles and style related files (SCSS or LESS files)
----- js/       // JavaScript files written for your app that are not for angular
----- libs/     // Third-party libraries such as jQuery, Moment, Underscore, etc.
index.html

This directory structure is much harder to read and understand from the get go. A newcomer to Angular may be completely turned off by this complex approach, and that is why you see tutorials and examples in Angular following the simpler directory structure found in examples earlier. Let’s dive into the directory structure above and see what’s going on here.

index.html

The index.html lives at the root of front-end structure. The index.html file will primarily handle loading in all the libraries and Angular elements.

Assets Folder

The assets folder is also pretty standard. It will contain all the assets needed for your app that are not related your AngularJS code. There are many great ways to organize this directory but they are out of scope for this article. The example above is good enough for most apps.

App Folder

This is where the meat of your AngularJS app will live. We have two subfolders in here and a couple JavaScript files at the root of the folder. The app.module.js file will handle the setup of your app, load in AngularJS dependencies and so on. The app.route.js file will handle all the routes and the route configuration. After that we have two subfolders – components and shared. Let’s dive into those next.

Components Folder

The components folder will contain the actual sections for your Angular app. These will be the static views ,directives and services for that specific section of the site (think an admin users section, gallery creation section, etc). Each page should have it’s own subfolder with it’s own controller, services, and HTML files.

Each component here will resemble a mini-MVC application by having a view, controller and potentially services file(s). If the component has multiple related views, it may be a good idea to further separate these files into ‘views’, ‘controllers’, ‘services’ subfolders.

This can be seen as the simpler folder structure shown earlier in this article, just broken down into sections. So you could essentially think of this as multiple mini Angular applications inside of your giant Angular application.

Shared Folder

The shared folder will contain the individual features that your app will have. These features will ideally be directives that you will want to reuse on multiple pages.

Features such as article posts, user comments, sliders, and others should be crafted as AngularJS Directives. Each component here should have it’s own subfolder that contains the directive JavaScript file and the template HTML file.

In some instances, a directive may have it’s own services JavaScript file, and in the case that it does it should also go into this subfolder.

This allows us to have definitive components for our site so that a slider will be a slider across the site. You would probably want to build it so that you could pass in options to extend it. For example, you could have:


<!-- user a slider directive to loop over something -->
<slider id="article-slider" ng-repeat="picture in pictures" size="large" type="square">
</slider>

Now this slider is accessible from any part of our site so we’re not reinventing the wheel. We also just have to change it in one place, the shared folder and it will update sitewide.

#Best Practices (For Huuuuge Apps)

If you are developing a really large application in AngularJS, you will want to go even further and modularize your app. Here are some additional tips on how to accomplish this.

Modularize the Header and Footer

A good practice here would be to create a Core subfolder under components, and then a subfolder for the Header and Footer and any additional components that will be shared across many pages.

Modularize the Routes

In the structure above we didn’t do this, but another good practice for very large apps is to separate the routes into separate files. For example you might add a blogRoutes.js file in the /views/blog/ subfolder and there include only the routes relevant to the blog such as /blog/:slug, /blog/:slug/edit, blog/tags:/tags, etc.

Don’t Forget to Minify

If you do decide to opt in and build your AngularJS apps in a modularized fashion, be sure to concatenate and minify your code before going into production. There are many great extensions for both Grunt and Gulp that will help with this – so don’t be afraid to split code up as much as you need.

You may not want to necessarily have just one giant .js file for your entire app, but concatenating your app into a few logical files like:

  • app.js (for app initialization, config and routing)
  • services.js (for all the services)

This will be greatly beneficial for reducing initial load times of your app.

If you need some more tips on minifying, check out our guide: Declaring AngularJS Modules For Minification

Keep the Names Consistent

This is more of a general tip, but this will save you a headache in the future, when writing components and you need multiple files for the component, try to name them in a consistent pattern. For example, blogView.html, blogServices.js, blogController.js.

#Benefits of the Modularized Approach

The example above shows a modularized approach to building AngularJS. The benefits of this approach include:

Code Maintainability

Follow the approach above will logically compartmentalize your apps and you will easily be able to locate and edit code.

Scalable

Your code will be much easier to scale. Adding new directives and pages will not add bloat to existing folders. Onboarding new developers should also be much easier once the structure is explained. Additionally, with this approach, you will be able to drop features in and out of your app with relative ease so testing new functionality or removing it should be a breeze.

Debugging

Debugging your code will be much easier with this modularized approach to app development. It will be easier to find the offending pieces of code and fix them.

Testing

Writing test scripts and testing modernized apps is a whole lot easier then non-modularized ones.

#In Conclusion

To conclude, this article covered some of the best practices in regards to structuring an AngularJS app. It is easy to ignore good practices in order to save time upfront. We all have a tendency to just want to start writing code. Sometimes this passion can hurt us in the long run when our awesome apps grow and become popular and then we’re stuck rewriting or even worse maintaining badly thought out code. I hope this article had some helpful tips.

I plan on building a barebones AngularJS application structure that should follow the best practices outlined in this article that will help you get started building Angular apps quickly and efficiently. Keep a lookout for that in the coming weeks. Stay tuned for Part 2 where we put these concepts into practice!

In the meantime, be sure to check out John Papa’s AngularJS Style Guide for additional tips on AngularJS best practices and while you’re add it give Todd Motto’s AngularJS Guide a look too.

20 useful tools for web developers

http://www.creativebloq.com/web-design/must-have-tools-developers-31411174

 

Improve your website’s performance, validate your code and more with these handy tools.

Life as a web developer may offer many rewards, but when project managers are asking you to do more and more in less and less time, it can become frustrating. So it’s always good to find tools that can make your work faster and more productive. Here we’ve gathered together some of the most useful.

ADVERTISING

Some you’ll have heard of, others you’ll already be using, but hopefully there’ll be at least one or two that can lighten your workload and brighten your day…

01. Browser Calories

Get the page weight of whatever you’re looking at

In a time when more of us are doing more of our browsing on a flaky mobile connection than ever before, as designers and developers we need to be keeping an eye on our page weights. This browser extension places an icon next to the address bar that, when clicked, lets you know the page weight of whatever your looking at, broken down by resource if you like.

02. Visual Studio Code

Visual Studio Code

A free, open source code editor from Microsoft that runs anywhere and has lots of smart features for making coding quicker and easier. Built-in Git commands, debugger and much more.

03. Firebug

Firefox add-on Firebug is a must-have for devs

From the developers at Firefox, the amazingly useful add-on Firebug enables you to debug, edit and monitor HTML, JavaScript and CSS live, all in the browser. One of the very best web development tools out there, this is a must-have for anyone working in web development.

04. HTML Entity Character Lookup

HTML Entity Character Lookup

HTML Entity Character Lookup helps you ensure all the characters on your page are validated

Using HTML entities is essential to ensure all the characters on your page are validated. However, often finding the right entity code requires scanning through 250 rows of characters. It’s also available as a widget on the Mac Dashboard.

05. -prefix-free

Prefix free

-prefix-free helps you break free from CSS prefix hell

This cool tool from Lea Verou lets you use unprefixed CSS properties. It essentially works behind the scenes, adding the current browser’s prefix to any CSS code, only when it’s needed.

06. Cloud9 IDE

Cloud9 IDE

Cloud9 IDE enables developers around the world to edit the same code and chat together

Cloud9 IDE is a tool to help you collaborate with others on big-scale code projects. Letting developers around the world edit the same code and chat together in realtime, it’s fast emerging as one of the best browser-based IDEs. Features include code completion and editor, drop-document trees, smart drag and FTP integration.

07. Foundation

Foundation3

Foundation 6 makes it “crazy fast” to code responsive designs, say its makers ZURB

Made by develpopers for developers at ZURB, this prototyping tool acts as a blueprint for your responsive design projects. Its latest version is an easy grid-structure that makes styling even more convenient and flexible. It works with both SASS and CSS.

08. Fontello

Fontello

Fontello offers an easy way to generate icons in web font form

This icon generator is truly one of a kind. Pick the icons you want and Fontello will compile them into customized web fonts. You can also edit and customize the symbol codes and names.

09. Cloud Comp

Cloud Comp

Share sites and apps with ease using Cloud Comp

This lightweight and easy to use tool helps you share website and apps with others. It’s been specifically built to give designers and developers a way to present comps to their clients inside of a realistic device shell.

10. BLOKK

BLOKK

BLOKK replaces dummy text with blocks

BLOKK is a fun-to-use font for “clients who do not understand Latin”. In other words, it replaces all text with blocks to suggest generic text instead. That way you can create good looking mock-ups and wireframes without confusing people with Lorem Ipsem.

11. Basecamp

Basecamp

Basecamp is the project management of choice for much of the web design industry

Developed by 37signals, Basecamp is a popular online tool to help you manage collaboration and project management with ease. It all runs in the cloud and most people working in web design and development will be familiar with it.

12. Browser Shots

Browser Shots

Browser Shots takes screenshots of your sites in different browsers

Browser Shots generates screenshots of how websites appear at 800×600 and 1024×768 resolution in six commonly used web browsers. Just submit the web address and a group of distributed computers will access and open it, then upload screenshots of the site for you to check out.

13. FavIcon Generator

FavIcon Generator

FavIcon Generator

A favicon (‘favorites icon’) is a small, 16×16 image that’s shown inside the browser’s location bar and bookmark menu when your site is called up. This tool makes it easy to create them for your site.

14. Web-developer toolbar

Web developer toolbar

The Web Developer extension adds a range of handy tools to the browser

This Firefox plug-in feature provides a number of useful tools that web developers use on a day-to-day basis. It’s particularly useful when inspecting your HTTP header information or when you need to validate your XHTML.

15. Load Impact

Load Impact

Load Impact simulates large amounts of traffic to test your site’s performance

A successful website is one that loads faster and quickly. Load Impact is a cloud-based service for load testing and website optimization that generates traffic load by simulating users. In other words it lets you test how your website, web app, mobile app or API will perform with up to 1.2 million concurrent users.

16. Lorem Ipsum Generator

Lorem Ipsum Generator

Lorem Ipsum Generator does exactly what you’d expect

If you’re not impressed with BLOKK (see 10) and want to stick with Lorem Ipsum, this reference site about the subject, giving information on its origins, also includes a random Lorem Ipsum generator.

17. W3c Markup Validation Service

W3c Markup Validation Service

W3c Markup Validation Service checks your documents for conformance to the relevant specification

Validating web documents is an important step that can dramatically help improving and ensuring their quality. This free service from the W3C helps you to check the markup validity of different web documents, in HTML, SMIL, XHTML and MathML and more.

18. Typetester

Typetester

Take fonts for a spin with Typetester

The Typetester is a browser tool for comparing different kinds of fonts, Choose the typeface you want to test out, along with your chosen size, tracking, colour etc, and Typetester applies it to a set piece of text so you can see what it will look like.

19. Pingdom

Pingdom

Pingdom is a great tool for monitoring your site’s performance

Pingdom is a service that tracks the uptime, downtime, and performance of websites. Upload a full page in HTML and it will mimic the loading process of the entire website, incorporating all the elements (namely JavaScript, RSS, CSS and images), thereby enabling you to check and monitor the efficiency of your site.

20. CSS Sprite Generator

CSS Sprite Generator

CSS Sprite Generator can help improve your site’s performance

By reducing the number of HTTP requests, this tool aims at increasing the loading speed of your website. Images are combined into one larger image at defined X and Y coorindates. Having assigned this generated image to relevant page elements the background-position CSS property can then be used to shift the visible area to the required component image.

100+ Awesome Web Development Tools and Resources

https://www.keycdn.com/blog/web-development-tools/

 

 

The best and worst thing about being a web developer is that the web is constantly changing. While this is exciting it also means that web developers must always be proactive about learning new techniques or programming languages, adapting to changes, and be willing and eager to accept new challenges. This could include tasks such as adapting existing frameworks to meet business requirements, testing a website to identify technical problems, or optimizing and scaling a site to better perform with the back-end infrastructure.  We thought we would compile a comprehensive list of web development tools and resources that can help you be more productive, stay informed, and become a better developer.

Web Development Tools and Resources for 2017

A lot fo these web development tools below are ones we use at KeyCDN on a daily basis. We can’t include everything, but here are a couple of our favorites and other widely used ones. Hopefully, you find a new tool or resource that will aid you in your development workflow. Note: The tools and resources below are listed in no particular order.

JavaScript Libraries

javascript libraries

Javascript is one of the most popular programming languages on the web. A Javascript library is a library of pre-written Javascript which allows easier access throughout the development of your website or application. For example, you can include a copy of Google’s hosted jQuery library by using the following snippet.

https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
  • jQuery: A fast, small, and feature-rich JavaScript library.
  • BackBoneJS: Give your JS app some backbone with models, views, collections, & events.
  • D3.js: A JavaScript library for manipulating documents based on data.
  • React: Facebook’s Javascript library developed for building user interfaces.
  • jQuery UI: A curated set of user interface interactions, effects, widgets, and themes.
  • jQuery Mobile: HTML5-based user interface system designed to make responsive web sites.
  • Underscore.js: Functional programming helpers without extending any built-in objects.
  • Moment.js: Parse, validate, manipulate, and display dates in JavaScript.
  • Lodash: A modern utility library delivering modularity, performance, & extras.

Front-end Frameworks

web development tools - front-end frameworks

Front-end frameworks usually consist of a package that is made up of other files and folders, such as HTML, CSS, JavasScript, etc. There are also many stand-alone frameworks out there. We are a big fan of Boostrap and the main KeyCDN website is built on it. A solid framework can be an essential tool for front-end developers.

  • Bootstrap: HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.
  • Foundation: Family of responsive front-end frameworks that make it easy to design beautiful responsive websites, apps and emails that look amazing on any device.
  • Semantic UI: Development framework that helps create beautiful, responsive layouts using human-friendly HTML.
  • uikit: A lightweight and modular front-end framework for developing fast and powerful web interfaces.

Web Application Frameworks

web application frameworks

A web application framework is a software framework designed to aid and alleviate some of the headache involved in the development of web applications and services. KeyCDN actually hosts a version of AngularJS, HTTP/2 and CORS enabled, that you can use in your projects completely free. See code below. Full documentation at angularcdn.com.

https://opensource.keycdn.com/angularjs/1.4.8/angular.min.js
  • Ruby: Ruby on Rails is a web-application framework that includes everything needed to create database-backed web applications, with the MVC pattern.
  • AngularJS: Lets you extend HTML vocabulary for your web application. AngularJS is a framework, even though it’s much more lightweight and sometime referred to as a library.
  • Ember.js: A framework for creating ambitious web applications.
  • Express: Fast and minimalist web framework for Node.js.
  • Meteor: Full-stack JavaScript app platform that assembles all the pieces you need to build modern web and mobile apps, with a single JavaScript codebase.
  • Django: High-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • ASP.net: Free, fully supported Web application framework that helps you create standards-based Web solutions.
  • Laravel: A free, open-source PHP web application framework to build web applications on MVC pattern.
  • Zend Framework 2: An open source framework for developing web applications and services using PHP.
  • Phalcon: A full-stack PHP framework delivered as a C-extension.
  • Symfony: A set of reusable PHP components and a web application framework.
  • CakePHP: A popular PHP framework that makes building web applications simpler, faster and require less code.
  • Flask: A microframework for Python based on Werkzeug and Jinja 2.
  • CodeIgniter: Powerful and lightweight PHP framework built for developers who need a simple and elegant toolkit to create full-featured web applications.

Also make sure to check out KeyCDN’s framework integration guides to see how you can implement a CDN with the solutions mentioned above.

Task Runners / Package Managers

build systems task runners

Tasks runners are all about automating your workflow. For example you can create a task and automate the minification of JavaScript. Then build and combine tasks to speed up development time. Package managers keep track of all the packages you use and make sure they are up to date and the specific version that you need.

  • Grunt: JavaScript task runner all about automation.
  • Gulp: Keeps things simple and makes complex tasks manageable, while automating and enhancing your workflow.
  • npm: Pack manager for JavaScript.
  • Bower: A web package manager. Manage components that contain HTML, CSS, JavaScript, fonts or even image files.
  • Webpack: A module bundler for modern JavaScript applications.

Languages / Platforms

programming languages

Behind all the web development tools is a language. A programming language is a formal constructed language designed to communicate with a computer and create programs in which you can control the behavior. And yes we realize some of these might not always be referred to as a language.

  • PHP: Popular general-purpose scripting language that is especially suited to web development.
  • NodeJS: Event-driven I/O server-side JavaScript environment based on V8.
  • Javascript: Programming language of HTML and the web.
  • HTML5: Markup language, the latest version of HTML and XHTML.
  • Python: Programming language that lets you work quickly and integrate systems more effectively.
  • Ruby: A dynamic, open source programming language with a focus on simplicity and productivity.
  • Scala: Scala is a pure-bred object-oriented language allowing a gradual, easy migration to a more functional style.
  • CSS3: Latest version of cascading style sheets used in front-end development of sites and applications.
  • SQL: Stands for structured query language used with relational databases.
  • Golang: Open source programming language that makes it easy to build simple, reliable, and efficient software.
  • Rust: Systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.
  • Elixir: Dynamic, functional language designed for building scalable and maintainable applications.

Databases

databases

A database is a collection of information that is stored so that it can be retrieved, managed and updated.

  • MySQL: One of the world’s most popular open source databases.
  • MariaDB: Made by the original developers of MySQL. MariaDB is also becoming very popular as an open source database server.
  • MongoDB: Next-generation database that lets you create applications never before possible.
  • Redis: An open source, in-memory data structure store, used as database, cache and message broker.
  • PostgreSQL: A powerful, open source object-relational database system.

CSS Preprocessors

web development tools - css preprocessors

A CSS preprocessor is basically a scripting language that extends CSS and then compiles it into regular CSS. Make sure to also check out or in-depth post on Sass vs Less.

  • Sass: A very mature, stable, and powerful professional grade CSS extension.
  • Less: As an extension to CSS that is also backwards compatible with CSS. This makes learning Less a breeze, and if in doubt, lets you fall back to vanilla CSS.
  • Stylus: A new language, providing an efficient, dynamic, and expressive way to generate CSS. Supporting both an indented syntax and regular CSS style.

If you are just getting started with a CSS preprocessor you might want to make the transition easier by first using a 3rd party compiler, such as the ones below.

Compiler Sass Language Less Language Mac Windows
CodeKit      
Koala        
Hammer    
LiveReload        
Prepros        
Scout      
Crunch      

Text Editors / Code Editors

text editors code editors

Whether you’re taking notes, coding, or writing markdown, a good text editor is a part of our daily lives!

  • Atom: A text editor that’s modern, approachable, yet hackable to the core. One of our favorites!
  • Sublime Text: A sophisticated text editor for code, markup and prose with great performance.
  • Notepad++: A free source code editor which supports several programming languages running under the MS Windows environment.
  • Visual Studio Code Beta: Code editing redefined and optimized for building and debugging modern web and cloud applications.
  • TextMate: A code and markup editor for OS X.
  • Coda 2: A fast, clean, and powerful text editor for OS X.
  • WebStorm: Lightweight yet powerful IDE, perfectly equipped for complex client-side development and server-side development with Node.js.
  • Vim: A highly configurable text editor built to enable efficient text editing.
  • Brackets: A lightweight and powerful modern text editor; written in JavaScript, HTML and CSS.
  • Emacs: An extensible, customizable text editor with built-in functions to aid in quick modifications of text and code.

Markdown Editors

markdown editors

Markdown is a markup language in plain text using an easy syntax that can then be converted to HTML on the fly. Note: This is different than a WYSIWYG editor. Markdown editors are sometimes referred to as the in-between WYSIWYG and simply writing code.

  • StackEdit: A free online rich markdown editor.
  • Dillinger: An online cloud-enabled, HTML5, buzzword-filled Markdown editor.
  • Mou: Markdown editor for developers on Mac OS X.
  • Texts: A rich editor for plain text. Windows and Mac OS X.

Some of the text editors we mentioned above also support markdown. For example, there is a markdown preview package for atom.

Icons

icons

Almost every web developer, especially front-end developers will at some point or another need icons for their project. KeyCDN actually hosts a version of Font Awesome, HTTP/2 and CORS enabled, that you can use in your projects completely free. See code below. Full documentation at fontawesomecdn.com.

https://opensource.keycdn.com/fontawesome/4.5.0/font-awesome.min.css
  • Font Awesome: Scalable vector icons that can instantly be customized — size, color, drop shadow, and anything that can be done with the power of CSS.
  • IconMonster: A free, high quality, monstrously big and continuously growing source of simple icons. One of our favorites!
  • Icons8: An extensive list of highly customizable icons created by a single design team.
  • IconFinder: Iconfinder provides beautiful icons to millions of designers and developers.
  • Fontello: Tool to build custom fonts with icons.

Git Clients / Services

git clients

Git is a source code management system for software and web development known for distributed revision control. When working with teams, using a git client to push code changes from dev to production is a way to maintain the chaos and ensure things are tested so they don’t break your live web application or site.

  • SourceTree: A free Git & Mercurial client for Windows or Mac. Atlassian also makes a pretty cool team Git client called Bitbucket.
  • GitKraken (Beta):  A free, intuitive, fast, and beautiful cross-platform Git client.
  • Tower 2: Version control with Git – made easy. In a beautiful, efficient, and powerful app.
  • GitHub Client: A seamless way to contribute to projects on GitHub and GitHub Enterprise.
  • Gogs: A painless self-hosted Git service based on the Go language.
  • GitLab: Host your private and public software projects for free.

Local Dev Environments

local dev environment

Depending upon what OS you are running or the computer you currently have access to, it might be necessary to launch a quick local dev environment. There are a lot of free utilities that bundle Apache, mySQL, phpmyAdmin, etc. all together. This can be a quick way to test something on your local machine. A lot of them even have portable versions.

  • XAMPP: Completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl.
  • MAMP: Local server environment in a matter of seconds on OS X or Windows.
  • WampServer: Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database.
  • Vagrant: Create and configure lightweight, reproducible, and portable development environments.
  • Laragon: A great fast and easy way to create an isolated dev environment on Windows. Includes Mysql, PHP Memcached, Redis, Apache, and awesome for working with your Laravel projects.

Diff Checkers

diff checkers

Diff checkers can help you compare differences between files and then merge the changes. A lot of this can be done from CLI, but sometimes it can be helpful to see a more visual representation.

  • Diffchecker: Online diff tool to compare text differences between two text files. Great if you are on the go and quickly need to compare something.
  • Beyond Compare: A program to compare files and folders using simple, powerful commands that focus on the differences you’re interested in and ignore those you’re not.

A lot of the free text editors we mentioned above also have plugins or extensions which allow you to diff or compare your files.

Code Sharing / Experimenting

code sharing

There is always that time when you are on Skype or Google hangout with another developer and you want him or her to take a quick look at your code. There are great team tools for sharing code like Slack, but if they aren’t a member of your team there are some great quick alternatives. Remember not to share anything secure.

  • JS Bin:  Tool for experimenting with web languages. In particular HTML, CSS and JavaScript, Markdown, Jade and Sass.
  • JSfiddle: Custom environment to test your JavaScript, HTML, and CSS code right inside your browser.
  • codeshare: Share code in real-time with other developers.
  • Dabblet: Interactive playground for quickly testing snippets of CSS and HTML code.

Collaboration Tools

dev collaboration tools

Every great development team needs a way to stay in touch, collaborate, and be productive. A lot of teams work remotely now. The team at KeyCDN is actually spread across many different continents. Tools like these below can help employees streamline their development workflow.

  • Slack: Messaging app for teams that is on a mission to make your working life simpler, more pleasant, and more productive. One of our favorites, we use this at KeyCDN!
  • Trello:  Flexible and visual way to organize anything with anyone. We also use this as KeyCDN.
  • Glip: Real-time messaging with integrated task management, video conferencing, shared calendars and more.
  • Asana: Team collaboration tool for teams to track their work and results.
  • Jira: Built for every member of your software team to plan, track, and release great software or web applications.

Inspiration

developers inspiration

We all need inspiration at some point or another. For front-end developers especially, from time to time, it can be beneficial to check out what other people are doing. This can be a great source of inspiration, new ideas, and making sure your web application or site doesn’t fall behind the times.

  • CodePen: Show off your latest creation and get feedback. Build a test case for that pesky bug. Find example design patterns and inspiration for your projects.
  • Dribble: A community of designers sharing screenshots of their work, process, and projects.

Website Speed Test Tools

website speed test tools

The speed of a website can be a critical factor to its success. Faster loading websites can benefit from higher SEO rankings, higher conversion rates, lower bounce rates, and a better overall user experience and engagement. It is important to take advantage of the many free tools available for testing website speed.

  • Website Speed Test:  A page speed test developed by KeyCDN that includes a waterfall breakdown and the website preview.
  • Google PageSpeed Insights: PageSpeed Insights analyzes the content of a web page, then generates suggestions to make that page faster.
  • Google Chrome DevTools: Set of web authoring and debugging tools built into Google Chrome.
  • WebPageTest: Run a free website speed test from multiple locations around the globe using real browsers (IE and Chrome) and at real consumer connection speeds.
  • Pingdom: Test the load time of that page, analyze it and find bottlenecks.
  • GTmetrix: Gives you insight on how well your site loads and provides actionable recommendations on how to optimize it.

You can see a more in-depth list on our post about website speed test tools.

Web Development Communities

web development communities

Every web developer has been there. They have a problem and what do they do? Well, they go to Google to find a quick answer. The web offers so much content right at our fingertips that it makes it easy to diagnose and troubleshoot problems when they arise. Check out a few good web development communities below.

Web Development Newsletters

web development newslettersThe last thing you probably need is another newsletter subscription. But these guys handpick some of the best web development and performance topics from around the web so you don’t have to!

  • wdrl.info: A handcrafted, carefully selected list of web development related resources. Curated and published usually every week.
  • webopsweekly.com: A weekly newsletter for Web developers focusing on web operations, infrastructure, deployment of apps, performance, and tooling, from the browser down to the metal.
  • web tools weekly: A front-end development and web design newsletter with a focus on tools. Each issue features a brief tip or tutorial, followed by a weekly round-up of various apps, scripts, plugins, and other resources.
  • freshbrewed.co: A weekly reading digest for front-end developers and UX designers.
  • smashingmagazine.com: Smashing Magazine is an online magazine for professional web designers and developers. Useful tips and valuable resources, sent out every second Tuesday.
  • front-end dev weekly: Front-end developer news, tools and inspiration hand-picked every week.
  • friday front-end: Front-end development links tweeted daily, emailed weekly.
  • /dev tips: Receive a developer tip, in the form of a gif, in your inbox each week.

And of course, you can subscribe to our newsletter if you haven’t already on the right hand side of this post.

Summary

As you can see there are hundreds of web development tools and resources available to help streamline your development workflow and hopefully aid you in being more productive. Again we can’t list every tool or resource, but if we forgot something important, feel free to let us know below in the comments.

Announcing the new Azure App Service

In a mobile first, cloud first world, every business needs to deliver great mobile and web experiences that engage and connect with their customers, and which enable their employees to be even more productive.  These apps need to work with any device, and to be able to consume and integrate with data anywhere.

I’m excited to announce the release of our new Azure App Service today – which provides a powerful new offering to deliver these solutions.  Azure App Service is an integrated service that enables you to create web and mobile apps for any platform or device, easily integrate with SaaS solutions (Office 365, Dynamics CRM, Salesforce, Twilio, etc), easily connect with on-premises applications (SAP, Oracle, Siebel, etc), and easily automate businesses processes while meeting stringent security, reliability, and scalability needs.

Azure App Service

Azure App Service includes the Web App + Mobile App capabilities that we previously delivered separately (as Azure Websites + Azure Mobile Services).  It also includes powerful new Logic/Workflow App and API App capabilities that we are introducing today for the very first time – along with built-in connectors that make it super easy to build logic workflows that integrate with dozens of popular SaaS and on-premises applications (Office 365, SalesForce, Dynamics, OneDrive, Box, DropBox, Twilio, Twitter, Facebook, Marketo, and more).

All of these features can be used together at one low price.  In fact, the new Azure App Service pricing is exactly the same price as our previous Azure Websites offering.  If you are familiar with our Websites service you now get all of the features it previously supported, plus additional new mobile support, plus additional new workflow support, plus additional new connectors to dozens of SaaS and on-premises solutions at no extra charge.

Web + Mobile + Logic + API Apps

Azure App Service enables you to easily create Web + Mobile + Logic + API Apps:

image

You can run any number of these app types within a single Azure App Service deployment.  Your apps are automatically managed by Azure App Service and run in managed VMs isolated from other customers (meaning you don’t have to worry about your app running in the same VM as another customer).  You can use the built-in AutoScaling support within Azure App Service to automatically increase and decrease the number of VMs that your apps use based on the actual resource consumption of them.

This provides an incredibly cost-effective way to build and run highly scalable apps that provide both Web and Mobile experiences, and which contain automated business processes that integrate with a wide variety of apps and data sources.

Below are additional details on the different app types supported by Azure App Service.  Azure App Service is generally available starting today for Web apps, with the Mobile, Logic and API app types available in public preview:

Web Apps

The Web App support within Azure App Service includes 100% of the capabilities previously supported by Azure Websites.  This includes:

  • Support for .NET, Node.js, Java, PHP, and Python code
  • Built-in AutoScale support (automatically scale up/down based on real-world load)
  • Integrated Visual Studio publishing as well as FTP publishing
  • Continuous Integration/Deployment support with Visual Studio Online, GitHub, and BitBucket
  • Virtual networking support and hybrid connections to on-premises networks and databases
  • Staged deployment and test in production support
  • WebJob support for long running background tasks

Customers who have previously deployed an app using the Azure Website service will notice today that they these apps are now called “Web Apps” within the Azure management portals.  You can continue to run these apps exactly as before – or optionally now also add mobile + logic + API app support to your solution as well without having to pay anything more.

Mobile Apps

The Mobile App support within Azure App Service provides the core capabilities we previously delivered using Azure Mobile Services.  It also includes several new enhancements that we are introducing today including:

  • Built-in AutoScale support (automatically scale up/down based on real-world load)
  • Traffic Manager support (geographically scale your apps around the world)
  • Continuous Integration/Deployment support with Visual Studio Online, GitHub, and BitBucket
  • Virtual networking support and hybrid connections to on-premises databases
  • Staged deployment and test in production support
  • WebJob support for long running background tasks

Because we have an integrated App Service offering, you can now run both Web and Mobile Apps using a single Azure App Service deployment.  This allows you to avoid having to pay for a separate web and mobile backend – and instead optionally pool your resources to save even more money.

Logic Apps

The Logic App support within Azure App Services is brand new and enables you to automate workflows and business processes.  For example, you could configure a workflow that automatically runs every time your app calls an API, or saves data within a database, or on a timer (e.g. once a minute) – and within your workflows you can do tasks like create/retrieve a record in Dynamics CRM or Salesforce, send an email or SMS message to a sales-rep to follow up on, post a message on Facebook or Twitter or Yammer, schedule a meeting/reminder in Office 365, etc.

Constructing such workflows is now super easy with Azure App Services.  You can define a workflow either declaratively using a JSON file (which you can check-in as source code) or using the new Logic/Workflow designer introduced today within the Azure Portal.  For example, below I’ve used the new Logic designer to configure an automatically recurring workflow that runs every minute, and which searches Twitter for tweets about Azure, and then automatically send SMS messages (using Twilio) to have employees follow-up on them:

image

Creating the above workflow is super easy and takes only a minute or so to do using the new Logic App designer.  Once saved it will automatically run within the same VMs/Infrastructure that the Web Apps and Mobile Apps you’ve built using Azure App Service use as well.  This means you don’t have to deploy or pay for anything extra – if you deploy a Web or Mobile App on Azure you can now do all of the above workflow + integration scenarios at no extra cost.

Azure App Service today includes support for the following built-in connectors that you can use to construct and automate your Logic App workflows:

image

Combined the above connectors provide a super powerful way to build and orchestrate tasks that run and scale within your apps.  You can now build much richer web and mobile apps using it.

Watch this Azure Friday video about Logic Apps with Scott Hanselman and Josh Twist to learn more about how to use it.

API Apps

The API Apps support within Azure App Service provides additional support that enables you to easily create, consume and call APIs – both APIs you create (using a framework like ASP.NET Web API or the equivalent in other languages) as well as APIs from other SaaS and cloud providers.

API Apps enable simple access control and credential management within your applications, as well as automatic SDK generation support that enables you to easily expose and integrate APIs across a wide-variety of languages.  You can optionally integrate these APIs with Logic Apps.

Getting Started

Getting started with Azure App Service is easy.  Simply sign-into the Azure Preview Portal and click the “New” button in the bottom left of the screen.  Select the “Web + Mobile” sub-menu and you can now create Web Apps, Mobile Apps, Logic Apps, and API Apps:

image

You can create any number of Web, Mobile, Logic and API apps and run them on a single Azure App Service deployment at no additional cost.

Learning More

I’ll be hosting a special Azure App Service launch event online on March 24th at 11am PDT which will contain more details about Azure App Service, a great demo from Scott Hanselman, and talks by several customers and analytics talking about their experiences.  You can watch the online event for free here.

Also check out our new Azure Friday App Service videos with Scott Hanselman that go into detail about all of the new capabilities, and show off how to build Web, Mobile, Logic and API Apps using Azure App Service:

Then visit our documentation center to learn more about the service and how to get started with it today.  Pricing details are available here.

Summary

Today’s Microsoft Azure release enables a ton of great new scenarios, and makes building great web and mobile applications hosted in the cloud even easier.

If you don’t already have a Azure account, you can sign-up for a free trial and start using all of the above features today.  Then visit the Microsoft Azure Developer Center to learn more about how to build apps with it.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at:twitter.com/scottgu

Using the tabindex attribute

https://www.paciellogroup.com/blog/2014/08/using-the-tabindex-attribute/

 

The HTML tabindex attribute is used to manage keyboard focus. Used wisely, it can effectively handle focus within web widgets. Used unwisely however, the tabindex attribute can destroy the usability of web content for keyboard users.

The tabindex attribute indicates that an element can be focused on, and determines how that focus is handled. It takes an integer (whole number) as a value, and the resulting keyboard interaction varies depending on whether the integer is positive, negative or 0.

To understand why the tabindex attribute has such a powerful effect on usability, it’s necessary to know something of the way keyboard interaction works. A keyboard user will typically move through web content using the tab key, moving from one focusable element to the next in sequential order.

Certain interactive HTML elements like links and form controls are focusable by default. When they’re included in a web page, their sequential order is determined by the source order of the HTML.


<label for="username">Username:</label>
<input type="text" id="username">

<label for="password">Password:</label>
<input type="password" id="password">

<input type="submit" value="Log in">

A keyboard user would tab first to the username field, then the password field, and finally to the log in button. All three elements take focus by default, and they’re accessed in the order that they appear in the source code. In other words, there’s no need to explicitly set the tabindexbecause it’s all handled effortlessly in the browser.

tabindex=0

When tabindex is set to 0, the element is inserted into the tab order based on its location in the source code. If the element is focusable by default there’s no need to use tabindex at all, but if you’re repurposing an element like a <span> or <div>, then tabindex=0 is the natural way to include it in the tab order.

It’s worth mentioning at this point that it’s easier to use a focusable HTML element wherever possible. For example, when you choose to use a <button> or <input type="checkbox">, keyboard focus and keyboard interaction are handled automatically by the browser. When you repurpose other elements to create custom widgets, you’ll need to provide keyboard focus and interaction support manually.

tabindex=-1

When tabindex is set to a negative integer like -1, it becomes programmatically focusable but it isn’t included in the tab order. In other words, it can’t be reached by someone using the tab key to navigate through content, but it can be focused on with scripting.

An example is moving focus to a summary of errors returned by a form. The summary would typically be located at the start of the form, so you want to draw the attention of screen reader/magnifier users to it, and to position all keyboard-only users at the start of the form so they can begin correcting any errors. You don’t want the error summary itself to be included in the tab order of the page though.


<div role="group" id="errorSummary" aria-labelledby="errorSummaryHeading" tabindex="-1">
<h2 id="errorSummaryHeading">Your information contains three errors</h2>
<ul>
...
</ul>
</div>

tabindex=1+

It’s when tabindex is set to a positive integer that things get problematic. It imposes a tab order on the content that bears no resemblance to the expected tab order.


<label for="username">Username:</label>
<input type="text" id="username" tabindex="3">

<label for="password">Password:</label>
<input type="password" id="password" tabindex="1">

<input type="submit" value="Log in" tabindex="2">

In this example the visual presentation of the form would be as expected: Username and password fields, followed by the log in button. The tab order would make no sense at all however. Focus would move first to the password field, then the log in button, and finally to the username field.

Things get worse when you realise that the password field would be the first focusable element on the page containing the form. It doesn’t matter how many focusable elements appear in the source order/visual presentation before the password field, the tabindex of 1 means it’ll be the first element to receive focus on the page.

The tabindex attribute is versatile, and it has the capacity to improve or destroy usability for keyboard-only users. When you think about using the tabindex attribute, keep these things in mind:

  • Use tabindex=0 to include an element in the natural tab order of the content, but remember that an element that is focusable by default may be an easier option than a custom control
  • Use tabindex=-1 to give an element programmatic focus, but exclude it from the tab order of the content
  • Avoid using tabindex=1+.

Further reading

Translations

About Léonie Watson

Léonie is Communications director and Principal engineer at TPG, co-chair of the W3C Web Platform Working Group working on HTML and Web Components, writer for Smashing magazine, SitePoint.com and Net magazine, and regular conference speaker.

Set focus on first invalid input in AngularJs form

https://stackoverflow.com/questions/20365121/set-focus-on-first-invalid-input-in-angularjs-form

 

Ok, so the answer was simpler than I thought.

All I needed was a directive to put on the form itself, with an event handler looking for the submit event. This can then traverse the DOM looking for the first element that has the .ng-invalid class on it.

Example using jQLite:

myApp.directive('accessibleForm', function () {
    return {
        restrict: 'A',
        link: function (scope, elem) {

            // set up event handler on the form element
            elem.on('submit', function () {

                // find the first invalid element
                var firstInvalid = elem[0].querySelector('.ng-invalid');

                // if we find one, set focus
                if (firstInvalid) {
                    firstInvalid.focus();
                }
            });
        }
    };
});

The example here uses an Attribute directive, you could expand the example to have this be an element directive (restrict: ‘E’) and include a template that converts this to a . This is however a personal preference.