Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Articles Tagged ‘javascript’

Pretty JavaScript tools for your website

Wednesday, September 5th, 2018 by Servage
There are many JavaScript tools out there, trying to help you adding some functionality to your website. Dialog, overlay, loader, image gallery, rating, social icons and many many more. The quality of those scripts is very different. And also the documentation and usage are at various levels. For new users to quickly find and integrate something without too many problems, both code quality and documentation are important. Have a look at this collection of JavaScript widgets for your website from no-margin-for-errors.com PrettyPhoto "prettyPhoto is a jQuery lightbox clone. Not only does it support images, it also support for videos, flash, YouTube, iframes and ajax. It’s a full blown media lightbox. It ...

Copy-to-clipboard with Javascript

Wednesday, August 22nd, 2018 by Servage
It's amazing what you can accomplish with Javascript. Frameworks like jQuery make it quite easy to get going with your own functionality. We have some articles about it here on the Magazine: Create a jQuery plugin and Element-specific data handling for jQuery plugins, and a presentation of Starter. You can pretty much do whatever you like, and quite fast as well, using jQuery, or similar Javascript technologies. The web also provides you with a whole lot of free/open-source scripts you can use, to add rich functionality to your web apps. Today I am going to show you how easy you can add a copy-to-clipboard function. "The Zero Clipboard library provides an easy way ...

Speed up your website – Part 4: JavaScript

Saturday, July 14th, 2018 by Servage
This is the fourth part of a simplified explanation of the "Yahoo best practices for speeding up your web site". Read the third part here. The third part is about CSS related optimization. Preferably place scripts at the bottom Scripts block parallel downloads of multiple items in the browser. Therefore you might want to place the scripts at the bottom of the page, if possible. It is a problem if your scripts alter the content of your document on the initial load, since you might want those scripts at the top. Make JavaScript (and CSS) external Including JavaScript and CSS in the HTML document reduces the amount of requests, but also ...

PHP-like in_array function in JavaScript

Monday, April 30th, 2018 by Servage
Recently I once more found myself in a situation where I really felt that I am a PHP-developer, more that a JavaScript-developer. Do you also find your self writing stuff like in_array() in JavaScript code? It happens often to me, that I take for granted in other languages, what I know and love in PHP. It also often takes quite a while to find a good alternative for missing functions in JavaScript, since Google often provides you with multiple options. One of the common functins I miss in JavaScript from PHP is in fact the "in_array"-function. Luckily there is a splendid JavaScript snippet here: function in_array (needle, haystack, argStrict) { ...

HTTP requests with the new Angular 4 HTTP Client

Tuesday, November 7th, 2017 by Servage
angular-4Angular 4.3 comes with a new way of sending HTTP requests: the HttpClient class. The older Http class can still be used and it is not deprecated, at least for now. However, HttpClient brings some new features and will likely replace the old class in the future. Let’s go through some of the features the new HttpClient has to offer. Modifying Requests with Interceptors One of the handy new features is the ability to intercept HTTP requests with interceptors. Intercepting a request means modifying it on the fly. One common use case for interceptors is to attach a session token to every request automatically to easily authenticate with an API. Interceptors are classes that ...

How JavaScript Promises Work

Sunday, October 15th, 2017 by Servage
javascript-codeA promise is an object that represents an asynchronous action that is yet to be completed. Consider an HTTP request that loads the details of a user account. If the request is sent inside a promise, your application can continue to work on other tasks while the HTTP request is sent. When it completes, a function is called where you can handle the data that was returned. Let’s have a closer look at promises and what makes them so powerful. Creating a Promise A new promise can be created with the new keyword using the Promise class. Promises are created inside a function that performs asynchronous tasks. Therefore, you could have the following ...

Building a Front End with Ember.js

Sunday, October 8th, 2017 by Servage
emberEmber.js is yet another JavaScript framework for building the UI for web applications. While there seems to be many JavaScript frameworks out there at the moment, each of them is targeted for a specific use case, or at least is more suitable for something than the others. Usually a single framework is not always the best choice for all kinds of websites and web applications. Let’s explore Ember together and figure out how it works and what types of websites benefit from it the most. Ember.js Quick Start If you have ever worked with Angular, chances are you find getting started with Ember quite easy. The process of setting up your first Ember ...

Angular 4 Best Practices

Monday, October 2nd, 2017 by Servage
angularAngular is one of the most popular front-end frameworks. Developers sometimes prefer to use their own approach when it comes to naming conventions, whitespace usage, file structure and so on. However, if every developer chooses their own path to follow, managing a single code base in a team becomes quite challenging. To solve this, Angular has a set of rules that all developers should follow when working on an Angular project. Let’s have a look at those recommendations set by the team behind Angular. File Names Let’s start with file and directory naming conventions. By following the Angular naming conventions, you can easily identify what a file does just by looking at the ...

What is Vue.js?

Tuesday, August 1st, 2017 by Servage
vueVue.js is a framework for building interactive user interfaces. It has gained quite a bit of popularity among front-end developers for being easy to use and working well in different types of projects. What is Vue.js more specifically and how does it work? Let’s find out. Vue for Views As the name might suggest, Vue.js is the V in MVC. You can use it to build the view side of your application without worrying about the rest of your technology stack because Vue.js works well with almost any type of back end. Vue utilizes the same approach with a virtual DOM as React, making it fast to render changes on a page. It is ...

Enhanced JavaScript with TypeScript

Tuesday, April 25th, 2017 by Servage
typescriptTypeScript is a relatively new programming language from Microsoft. It is a superset of JavaScript and adds some useful features to make JavaScript coding easier and less prone to errors. What does that mean and what are these useful features? Let’s find out! Static Type Checking As the name suggests, TypeScript introduces type checking. In practise this means that variables can now have a type. In typical JavaScript, all variables are created with the var keyword in ES5 and with let in ES6. The variables are automatically assigned the correct type based on what value the variable holds. This makes JavaScript a dynamically typed language. However, TypeScript is a statically typed language since ...