background preloader

Introduction to JavaScript Source Maps - HTML5 Rocks

Introduction to JavaScript Source Maps - HTML5 Rocks
Have you ever found yourself wishing you could keep your client-side code readable and more importantly debuggable even after you've combined and minified it, without impacting performance? Well now you can through the magic of source maps. Basically it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location. Demo: Get original location The above demo allows you to right click anywhere in the textarea containing the generated source. Real world Firefox 23+ has source maps enabled by default in the built in dev tools. So... Demo: View scripts panel (with source maps) on fontdragr.com Why should I care about source maps? How does the source map work? Potential XSSI issues Related:  articles

Changing Drop Down selector Arrow Each browser displays select elements differently and it’s usually the one thing that will stop your forms from looking amazing. Where is with a regular button it’s fairly easy to change it, changing the selector arrow is another story. Just look at some of the possible variations (and those are outdated)! There are many tutorials out there to change the selector drop down. Unfortunately many of them involve placing an image over the entire element or creating your own image and sticking it in the corner. The below solution will work for all browsers and only take seconds to implement and only needs some CSS! How does it work? Simple, we hide the standard arrow, then we create “<>” text and just rotate it 90 degrees. basic select html code <div class="selectdiv"><label><select><option selected> Select Box </option><option>Option 1</option><option>Option 2</option><option>Last long option</option></select></label></div> The CSS : So the final magical CSS that will make this work is:

Change the Default Select Drop-Down List In this article I’m going to help you style a Select drop-down input with just CSS without the need for javascript. Ok let’s get to it! So here’s the story – The awesome designer in your team sends you a new PSD (Photoshop Document) with the final design of a new website or app. You go through the different documents looking at all the pages that will be be included in the new site. Well the reality is that you shouldn’t complain to the designer because little things like this makes you push yourself a little bit harder and not rely on default stylings just because. This article is based on two workarounds (One for Chrome and Safari and one for Firefox) already posted on the web. Credit for Chrome workaround goes to Chris Coyier from CSS-tricks.com Credit for Firefox workaround goes to João Cunha who posted this on stackoverflow Ok let’s get started! Let’s say that the design for the drop-down is this one: When we add the html for a Select Dropdown we get this: Firefox Default styling

Create animations on page scroll using CSS Hi there, you probably seen this done many times on web sites before. You get to the site and as you scroll elements will animate in (ex bounce, fade in etc). Today we are going to learn how to do this quickly. For this tutorial we are going to use animate.css this file will have all of our animations already created and you can just pick the ones you want to use. The whole scroll magic will come from a small script called Wow.js All you have to do is drop it into your page and you are done. Final Result See the Pen mejvpj What we will use: animate.css – can be downloaded herewow.js – can be downloaded here Setup The reason we are using animate.css is because it comes pre built with almost all animations you can think of. First things first import our files: We are using CloudFlare CDN services (cdnjs.com which you should too to save on your bandwidth!) Now we just need to add initialization of our script on to the html page itself: <script> new WOW().init(); </script> Creating basic html <!

Créer un menu contextuel avec HTML5 - JavaScript / jQuery | Creative Juiz Vous vous souvenez certainement des scripts JS qui permettent de hacker le clic-droit afin de proposer un menu contextuel personnalisé ? Sachez qu’il est possible depuis peu de le faire grâce à du HTML et un bout de JS. HTML5 étend les capacités de l’élément menu grâce à un nouvel attribut. On est d’accord, en dehors des problèmes d’accessibilité qu’implique ce genre de modification, le changement de ce bout d’interface pour l’utilisateur n’est clairement pas conseillé. En effet l’utilisateur qui utilise son clic-droit dans son navigateur a l’habitude des commandes dont il peut bénéficier, en ajouter ou les modifier peut s’avérer perturbateur pour lui. Ce n’est pas parce que vous pouvez le faire qu’il FAUT nécessairement le faire ! Puis entre nous cacher des commandes dans un clic-droit… m’enfin, si jamais vous avez besoin de ce genre de chose, voici comment faire. Place au code L’élément HTML menu permet de créer de base… un menu, oui. Voici le code HTML proposé. Démonstration

A Preview of HTML 5 Abstract#section1 The web is constantly evolving. New and innovative websites are being created every day, pushing the boundaries of HTML in every direction. HTML 4 has been around for nearly a decade now, and publishers seeking new techniques to provide enhanced functionality are being held back by the constraints of the language and browsers. Article Continues Below To give authors more flexibility and interoperability, and enable more interactive and exciting websites and applications, HTML 5 introduces and enhances a wide range of features including form controls, APIs, multimedia, structure, and semantics. Work on HTML 5, which commenced in 2004, is currently being carried out in a joint effort between the W3C HTML WG and the WHATWG. Note that the specification is still a work in progress and quite a long way from completion. Structure#section2 HTML 5 introduces a whole set of new elements that make it much easier to structure pages. <body><header>... <footer>© 2007 Example Inc. <!

Please Stop Using Local Storage Seriously. Just stop it already. I don’t know what it is, exactly, that drives so many developers to store session information in local storage, but whatever the reason: the practice needs to die out. Almost every day I stumble across a new website storing sensitive user information in local storage and it bothers me to know that so many developers are opening themselves up to catastrophic security issues by doing so. Let’s have a heart-to-heart and talk about local storage and why you should stop using it to store session data. What is Local Storage? I’m sorry if I was a bit grumpy earlier. Let’s start with the basics: local storage is a new feature of HTML5 that basically allows you (a web developer) to store any information you want in your user’s browser using JavaScript. In practice, local storage is just one big old JavaScript object that you can attach data to (or remove data from). What’s Cool About Local Storage? For one thing: it’s pure JavaScript! What Sucks About Local Storage

Comprendre z-index et les contextes d'empilement - Vincent De Oliveira Cet article est une traduction de What No One Told You About Z-Index écrit par Philip Walton le 22 décembre 2012. Ce que personne ne vous a dit sur z-index Le problème avec z-index, c’est que très peu de personnes ont réellement compris son fonctionnement. Ce n’est pas très compliqué, mais si vous n’avez jamais pris le temps de lire la spécification, il y a certainement des aspects cruciaux qui vous ont échappé. Vous ne me croyez pas? Ok, voyons si vous pouvez résoudre ce problème? Le problème Dans le HTML suivant, vous avez trois <div>, et chaque <div> contient un seul élément <span>. Voici à quoi ressemble le HTML et le CSS. <div><span class="red">Red</span></div><div><span class="green">Green</span></div><div><span class="blue">Blue</span></div> Le challenge: essayez de faire passer le <span> rouge derrière les éléments bleu et vert en respectant ces règles: Pour vérifier que vous avez bien compris, cliquez sur «Edit on CodePen» et jouez un peu avec. La solution Ordre d’empilement global

A practical guide to learning front end development for beginners by Nikita Rudenko I started my coding journey in spring 2018, a bit less than one year ago. I earned some programming skills since that time but still, I understand there are many more things to learn ahead. Anyway, I decided to gather these tips in a single place to help future developers on their path. This article is the guide I would have liked to have found when I started my journey. Before Starting If you decided to study on your own, there is a lot of information on the Internet and it’s hard to wrap your head around everything. Please note that these are just the first steps into the front-end universe. As a disclaimer, please note that the following resources are not an advertisement. As a starting point, I recommend signing up on freeCodeCamp. Curriculum. Pro tip: you can create an account on Twitter, if you don’t have one yet, and publicly commit to the 100DaysOfCode challenge. Now we are all set to start! Responsive Web Design The Basics CSS Flexbox CSS Grid Practice Algorithms Sass

The failed promise of Web Components – Lea Verou Web Components had so much potential to empower HTML to do more, and make web development more accessible to non-programmers and easier for programmers. Remember how exciting it was every time we got new shiny HTML elements that actually do stuff? Remember how exciting it was to be able to do sliders, color pickers, dialogs, disclosure widgets straight in the HTML, without having to include any widget libraries? The promise of Web Components was that we’d get this convenience, but for a much wider range of HTML elements, developed much faster, as nobody needs to wait for the full spec + implementation process. Or, that was the idea. Perusing the components on webcomponents.org fills me with anxiety, and I’m perfectly comfortable writing JS — I write JS for a living! Besides setup, the main problem is that HTML is not treated with the appropriate respect in the design of these components. Even when JS is unavoidable, it’s not black and white. Can we fix this? Plug and play.

Never use the Dot operator in JavaScript, for Data The Dot operator is dangerous because if, at run-time, the value of the identifier before it is not what was intended, the program will likely throw an error and probably crash. Firstly, there are of course cases where the dot operator is perfectly fine. Knowing where, and why, is what this article is about. But mostly it is about destructuring which I believe is the undervalued & underused solution. Destructuring is undervalued & highly underused. Secondly, let’s from the start acknowledge that with ES2019 two new operators were introduced to JavaScript: Optional chaining: ?. These make it possible to write user?. These are fine, but not as great as destructuring. But hey… Perhaps you’re playing with some home automation script, and you type out a helper function for some data structure, like below. const getTemperature = (atticData) => atticData.celsius || 15; This function will have two serious problems: What if the object you give the function is uninitialized at some point, undefined? No.

Related: